First try on Mod Rewrite

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

Postby wxwx » Tue May 19, 2009 10:12 pm

Yes, looks like the script problem.. grid|completed-orders working fine.

Abou redirect loop on # Remove .php

I tested on another server it's working.. but only on current server the mod is not working.. There have a problem to the lightspeed web server?

Thank you very much richardk. You help me and all of us so much!
:wink:
wxwx
 
Posts: 8
Joined: Tue May 12, 2009 4:42 pm

Postby richardk » Wed May 20, 2009 8:48 am

I do not get a redirect loop. Clear your browser's cache and try
Code: Select all
Options +FollowSymLinks
DirectoryIndex index.php

RewriteEngine On

RewriteBase /product/

# Remove index.php
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(html?|php)(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.(html?|php)$ ./$1 [R=301,L]

# Remove .php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^(.+)\.php$ ./$1/ [R=301,L]

# Force trailing slashes.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# /file/ to /file.php
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} ^(/.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule ^([^/]+)/?$ ./$1.php [QSA,L]

# reset part
RewriteRule ^forgot/(invalid|success)/?$ ./forgot.php?todo=$1 [QSA,L]

# category part
RewriteRule ^category/([0-9]+)(?:/([^/]+)(?:/([^/]+))?)?/$ ./category.php?pid=$1&cname=$2&scatname=$3 [QSA,L]

# paging part
RewriteRule ^page/([^/]+)/$ ./index.php?p=$1 [L]
RewriteRule ^(grid|completed-orders|history|list-view|pending-orders)/page/([0-9]+)/$ ./$1.php?p=$2 [QSA,L]

# product details
RewriteRule ^[^/]+/([0-9]+)/?$ ./details.php?pid=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 124 guests

cron