CMSMS nice urls - mod-rewrite

I am using CMSMS for a work project and haven't much experience with it myself. I have a videos page which lists every video by category. Each video links to:
/newsandresources/single-video-page/&referenceId=networks
where 'networks' is replaced with a reference ID attached to the video. What I need to do is create a mod_rewrite rule to re-direct:
/newsandresources/know-your-audience
(or whichever reference ID) to the single video's page and pass the reference ID
/newsandresources/single-video-page/&referenceId=know-your-audience
Does that make sense? :-/ sorry if not. I've come up with the follow mod_rewite code so far:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^newsandresources/([a-zA-Z0-9\-]+)/$ /newsandresources/single-video-page/&referenceId=$1
RewriteRule ^newsandresources/([a-zA-Z0-9\-]+)$ /newsandresources/single-video-page/&referenceId=$1
unfortunately it's not working. wondering if thee's anyone out there able to help?

try this:
RewriteRule ^\/newsandresources\/([a-zA-Z0-9\-]+) /newsandresources/single-video-page/&referenceId=$1

Related

Joomla not finding index.php after

I had turned Use URL rewriting to ON
Added some code in to the ht access file and this never worked.
I then turned off url rewriting and removed the code and now when I try to go to the website I am getting a 404 error.
I can still access /administration
the website is www2.daxtra.com
the page it should find is http://www2.daxtra.com/index.php/home
Does anyone have any ideas what has happened?
This was the code I added:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Thanks
Right, I've done a small test.
To get what you want, you need to following:
htaccess.txt (you don't need a .htaccess file)
Search Engine Friendly URLs set to On
Use URL rewriting set to Off
You finally need to ensure that your Homepage menu items it set to a specific component such as an article or something else, not an Alias
This will ensure that you get example.com/index.php/home
Hope this helps

Single instance of Joomla!, subdirectories and multiple domains

We recently moved a number of static websites from multiple (regional) domains onto a single .com domain which uses Joomla! to serve up content. The new site uses subdirectories and allows uses to navigate between countries. Like this:
newdomain.com/country-name1
newdomain.com/country-name2
newdomain.com/country-name3
We would now like each site to go back to having it’s own domain, but to essentially serve up the same website the user would be seeing by viewing the sub directory (we’ll probably drop the ability to navigate between countries, back that’s largely irrelevant to this post).
How can we do this with as little work as possible to the templates whilst retaining a single Joomla! instance? Has anyone got any experience of similar? I've read some articles but am not sure any of them give the user a true sense of being on a separate domain. I could of course be wrong (tbh, this is a little out of my field of expertise). Spoon-feeding appreciated. :)
You could try mapping the requests to the relevant folders
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain\.com [NC]
RewriteRule ^/(.*) /country-name1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain\.fr [NC]
RewriteRule ^/(.*) /country-name2/$1 [L]
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain\.de [NC]
RewriteRule ^/(.*) /country-name3/$1 [L]
That should map a request for
newdomain.com/country-name1/somepage to newdomain.com/somepage
newdomain.com/country-name2/page to newdomain.fr/page
etc
Obviously you'd also have to make all domain names resolve to the same folder.

domain.com/username mod rewrite in codeigniter

I'm new to mode rewrite thing. Started off with codeigniter a couple of days back and trying to get a hand at it. I'm developing a website which needs domain.com/USERNAME for better SEO results. But I'm unable to figure out as to what mod rewrite I should write to achieve this. I already have removed the index.php entry in config and my base url is http://127.0.0.1/myproject/. (I'm using XAMPP)
So I have to search for username in this format
http://127.0.0.1/myproject/USERNAME
and return the corresponding page. My current mod rewrite file goes as follows :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Any suggestions?
Thank you for your help :-)
http://daparky.com/codeigniter-vanity-username-personalised-urls/
this should solve your problem.

How to use mod_rewrite with anchors but no [R=301]

I have a website build on jQuery scrollTo plugin. Each page is accessible via anchor's, ie.
www.domain.com/#page-one
and deeper
www.domain.com/#page-one--some-content.
I'd like to create rule with mod_rewrite so address like
www.domain.com/page-one
or
www.domain.com/page-one/some-content
point to the above one. Its quite easy with [R=301] flag but I need my "clean" address /page-one/some-content to stay in address bar not changing to #page-one--some-content.
Why I need to change them? Because for some reasons I need to use alternative site for MSIE and Opera, kind of regular one with reloading every page. I need the same links for both sites which is obvious, I think.
I spent lots of time digging & reading about anchors in URL's and stuff, but I haven't reach my goal. If any one can help me, I'll appreciate!
Thanks, Kuba.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule (.*) /index.php#$1 [NE]
This works excellent for me.

Apache Redirection

I would have thought I'd find a TON of stuff out there about how to do this, but everything I try puts me into a redirection loop that causes the browser to eventually give up. I need to temporarily redirect all traffic to a site to the homepage of that site. Essentially:
RedirectMatch 302 /.* http://mysite.com
Let's chalk it up to the national holiday or working on a Sunday morning, but I can't find right solution to capture all traffic to any location within the site and redirect it to the homepage. I know I'm missing something obvious, but it's lingering in my blind spot...
Thanks.
Final solution:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^/index\.php.+$ / [QSA,L,R=302]
How about something like
RewriteEngine on
RewriteRule ^/(.+)$ http://mysite.com [L,R=302]
This is a fancier form for similar rule. Also, + stands for "one or more" while your * stands for "zero or more".

Resources