Forum Moderators: phranque
Anyways, what I'm having trouble with is the ability to redirect various pages that have filenames like /index.php?option=com_content&view=article&id=68& ;Itemid=61 to the root of my site. I can't seem to do it. Nothing I've tried worked, so I deleted the attempts.
Here's my .htaccess file so far:
<Files ~ "^.(htaccess¦htpasswd)$">
deny from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.example\.com)(:80)? [NC]
RewriteRule ^(.*) http://example.com/$1 [R=301,L]
order deny,allow
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://example.com/$1 [R=301,L]
Redirect permanent /cj/consulta/index.php http://example.com
order deny,allow
Redirect permanent /indexbc70.html http://example.com/index70.php?option=com_content&view=ar ticle&id=45&Itemid=54
order deny,allow
Redirect permanent /index.php http://example.com
AddHandler application/x-httpd-php5 .html
Help would be greatly appreciated, as would any pointers to a good tutorial for non-programmers. I've tried a few , but either little of it made sense to me, or it was too basic.
[edited by: jdMorgan at 12:41 am (utc) on April 1, 2009]
[edit reason] example.com [/edit]
The Options line needs to go first.
The index redirect needs to go before the non-www redirect.
The very specific page redirects need to go before all of the other redirects.
There's a better way to code the index redirect, and it was posted here only a few hours ago.
[webmasterworld.com...]
I cleaned up the code, but am still having problems. The 1 thing I can't seem to do is redirect a call for www.mysite.com/index.php?option=com_content&view=article&id=58&Itemid=85 into www.mysite.com
What's currently happening is that a call for www.mysite.com/index.php?option=com_content&view=article&id=58&Itemid=85 gets redirected to www.mysite.com/?option=com_content&view=article&id=58&Itemid=85
This is my new .htaccess file:
<Files ~ "^.(htaccess¦htpasswd)$">
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteRule ^cj/consulta/index.php$ http://www.example.com [R=301,NC]
RewriteRule ^indexbc70.html$ http://example.com/index70.php?option=com_content&view=article&id=45&Itemid=54 [R=301,NC]
RewriteRule ^(.*)index\.php(.*)? http://www.example.com/$1 [R=301,NC]
# Externally redirect requests for index.html in any directory to "/" in that directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]
# Externally redirect requests for *all* non-canonical hostnames to canonical hostname, including case errors and appended FQDN indicator and/or port numbers.
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
AddHandler application/x-httpd-php5 .html
Any ideas what I'm doing wrong?
[edited by: jdMorgan at 12:42 am (utc) on April 1, 2009]
[edit reason] example.com [/edit]
<Files ~ "^.(htaccess¦htpasswd)$">
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=10
RewriteRule ^cj/consulta/index.php$ [mysite.com...] [R=301,NC]
RewriteRule ^indexbc70.html$ [mysite.com...] [R=301,NC]
RewriteRule ^(.*)index\.php(.*)? [mysite.com...] [R=301,L]
# Externally redirect requests for index.html in any directory to "/" in that directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ [mysite.com...] [R=301,L]
# Externally redirect requests for *all* non-canonical hostnames to canonical hostname, including case errors and appended FQDN indicator and/or port numbers.
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
AddHandler application/x-httpd-php5 .html
------------------------------------
Now let's say I wanted the site to redirect from www to non-wwww pages, is this the way?
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
I did not escape the "." in [index.php], but it still seems to work. So I don't think I understand when escapes are needed. I though that in a string between ^ and $ any special character needed escaping.
but it still seems to work
Of course since the period is "any character", too. If you escape it, it won't match any character but a literal period.
So I don't think I understand when escapes are needed.
Any time when something which has a special meaning in a specific environment shouldn't have its special meaning.