PDA

View Full Version : .htaccess mod_rewrite


absolethe
January 30th, 2005, 00:21
This looks really easy in the tutorials but I am getting a 404 error. I've tried it several different ways.

RewriteCond %{REQUEST_URI} !^/Sections/([A-Za-z]+)/([A-Za-z]+)/([0-9]+)(/)?$
RewriteRule (.*)/preview.php?s=$1&p=$2&i=$3 [L]
RewriteCond %{REQUEST_URI} !^/Sections/([A-Za-z]+)/([A-Za-z]+)(/)?$
RewriteRule (.*)/pages.php?s=$1&p=$2 [L]
RewriteCond %{REQUEST_URI} !^/Sections/([A-Za-z]+)(/)?$
RewriteRule (.*)/pages.php?s=$1 [L]

(with and without the ! and $ and with and without a space after (.*))

RewriteRule ^/Sections/([A-Za-z]+)/([A-Za-z]+)/([0-9]+)$ /preview.php?s=$1&p=$2&i=$3
RewriteRule ^/Sections/([A-Za-z]+)/([A-Za-z]+)$ /pages.php?s=$1&p=$2
RewriteRule ^/Sections/([A-Za-z]+)$ /pages.php?s=$1

In various orders with and without (/)? before the $ and without and without the / after the ^.

If I test using http://URL/Sections/Design I get a file not found error. Tried it both on my localhost and my live site.

'Bout to shoot myself in the foot.

absolethe
January 30th, 2005, 00:28
PS: the file it's telling me it's unable to find is (localpath/url)/Sections/Design. Which is funny to me (hilarious) because (a) that's not what it's supposed to find and (b) it's not supposed to exist.

sonicgroup
January 30th, 2005, 02:15
Personally, I'd use (.*) rather than ranges and sort out only valid entries in the actual site code as a) it's faster, b) it places less strain on the server, and c) it's easier.

absolethe
January 30th, 2005, 02:17
I just tried that too and it didn't work. :( My code already sorts out valid entries... *sigh* I'll try it again though. (This is seriously getting on my nerves.)