Rewrite problem... need index.php? to root

New to mod_rewrite? This is a good place to start.

Rewrite problem... need index.php? to root

Postby jakubsnm » Sat Jul 25, 2009 5:29 am

I have a .htaccess file with the following, I have no idea how these files work.

Code: Select all
RewriteEngine On
RewriteRule (.+)\.ht$ shop.php?name=$1 [L] 
RewriteRule (.+)\.html$ auction_details.php?name=$1 [L] 
RewriteRule (.+)\.cfm$ categories.php?parent_id=$1 [L]
RewriteRule ^(.*),(.*)$ $2.php?rewrite_params=$1&page_url=$2

RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]


All I would like is if someone could help me add some code that redirects the page "http://www.mysite.com/index.php?" to http://www.mysite.com/ as most links linking to my domain end up on index.php? not sure what the question mark comes up for but i have a feeling it's not good for my SEO.

Any help greatly appreciated.
Thanks guys
:)
jakubsnm
 
Posts: 1
Joined: Sat Jul 25, 2009 5:25 am

Postby richardk » Sat Jul 25, 2009 2:42 pm

I have no idea how these files work.

Regular expressions are tested against (parts of) the URL and substitutions made if they match.

Try
Code: Select all
RewriteEngine On

RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule .*  - [F,L]

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.php\?\  [NC]
RewriteRule ^(.+/)?index\.php$ /%1 [QSA,L]

RewriteRule ^(.+)\.ht$ /shop.php?name=$1 [L]
RewriteRule ^(.+)\.html$ /auction_details.php?name=$1 [L]
RewriteRule ^(.+)\.cfm$ /categories.php?parent_id=$1 [L]
RewriteRule ^(.+),(.+)$ /$2.php?rewrite_params=$1&page_url=$2


not sure what the question mark comes up for but i have a feeling it's not good for my SEO.

The question mark is unlikely to cause a problem with SEO. The index.php might.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 31 guests

cron