Forum Moderators: phranque
I'm trying to get an old set of URLs redirecting to a new set (I've migrated my site to a new CMS) and am having trouble. Specifically I want to redirect requests to "/page/number" to "/content/view/number/1" where number is the article number.
The contents of my .htaccess file are as follows:
RewriteEngine On
RewriteRule ^(content/¦component/) index.php
...and various redirects like this:
Redirect /rss [someurl.com...]
I've tried adding the following below the second line in the above code with no luck...
ReWriteRule ^page/([^/]+)$ /content/view/$1/1 [L]
Any ideas? Thanks in advance!
If not, you'll need to 'set up' and 'enable' mod_rewrite. Depending on how your server is configured, you may or may not need the first directive, but you'll always need the second:
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^page/([^/]+)/?$ /content/view/$1/1 [L]
Jim
RewriteEngine on
#
RewriteRule ^page/([^/]+)/?$ /content/view/$1/1 [L]
RewriteRule ^(content/¦component/) index.php
Unfortunately I'm still getting 404s on any urls in the following format:
[domain.com...]
Where 123 is the article number corresponding to the new URL in the following manner:
[domain.com...]
Thanks for all advice so far, any more ideas?
If you intend that the output of the first rule be passed to the second (an inefficient implementation, BTW), then you cannot use the [L] flag on the first rule, because that means that if it matches, then it is to be treated as the [L]ast rule on this pass...
Jim
I am not using the options directive as it knocks my site over when I use it and I have no more rules present, they are all commented out with #'s.
The first rule takes a requested URL (the result of a visitor clicking on a link on one of your pages), and rewrites it to /content/view/<something>/1
The second rule takes anything that starts with "/content" and rewrites it to index.php.
Therefore, the output of the first rule can be rewritten by the second rule, as long as there is no [L] flag on the first rule.
In "internal rewrite mode," which is what you are using here, the pattern on the left matches a browser-requested URL, and if there is a match, then Apache serves the content from the substitution URL-path on the right. So, the pattern on the left matches a URL which may or may not be directly associated with a real existing file, and the path on the right points to an existing file or script on your server -- Requested URLs on the left, real files on the right.
For more information, see the documents cited in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim