Forum Moderators: phranque
I have an old site that was recently converted to a php (expression engine cms site) all the old content is gone and I need to redirect the pages to the proper place except i'm having issues with my 301 redirect...
the old url is [domain.com...]
the new url is [domain.com...]
the redirect method I tried was
Redirect 301 /contentpage.asp?ContentID=7 [domain.com...]
but that is not working and im assuming it has something to do with the parametrized url (?ContentID=7) I would appreciate if anyone could help out here and would be greatly appreciative.
Thank You
Russ
RewriteCond %{QUERY_STRING} ^ContentID=7$
RewriteRule ^contentpage\.asp$ [domain.com...] [R=301,L]
RewriteCond %{QUERY_STRING} &?ContentID=7&?
RewriteRule ^contentpage\.asp$ http://www.example.com/abou[b]t/?[/b] [R=301,L]
Options +FollowSymLinks
RewriteEngine on
Jim
[old rules and I need these]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
[end old rules] ------expression engine cms uses these------
[ redirect rules ] ----works when i remove above rules -------
RewriteCond %{QUERY_STRING} &?ContentID=7&?
RewriteRule ^contentpage\.asp$ http://www.example.com/about/? [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} &?ContentID=7&?
RewriteRule ^contentpage\.asp$ http://www.example.com/about/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
However, I would also add a couple more rules.
After the first redirect I would add a rule which fixes URL requests asking for an index file by name to redirect to URL at www with trailing slash and no index file name.
After that I would have the general non-www to www redirect that fixes all non-www requests and preserves the requested filepath when redirecting to www.
After that I would list the rewrite.
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9\-]*)\.com$
RewriteRule ^.*$ [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
people can get to my page via [domain.com...] or [domain.com...] somone said I need to force the ar of the backslash which I am trying like this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}¦/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
but this isnt working and Im going seriously bald...lol
You do that with a redirect, but again, a redirect must contain the full domain name in the target URL otherwise that redirect creates a non-www and www duplicate URL, which then gets corrected by a later redirect creating a redirection chain. Fix the www part within the same redirect for these requests.
There's plenty of prior example code for removing the slash.