Rewrite Issue - Skipping Rule?

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

Rewrite Issue - Skipping Rule?

Postby Athrus » Tue Jul 21, 2009 7:30 pm

Hey guys, I'm not new to regexp but I am to mod_rewrite.

So, on my server I am trying to rewrite host.ca/xyz to host.ca/xyz.php and that works.

I am also trying to rewrite host.ca/quote/jkl to host.ca/quote.php?package=jkl

but that doesn't work and i have no idea as to why.

Here are my rewriting rules
Code: Select all
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule .* - [L]
    RewriteRule ^/quote/([a-z0-9-]*)$ /quote.php?package=$1 [L]
    RewriteRule ^/clients /soon.php [L]
    RewriteRule ^/([^/]+)$ /$1.php [L]


Any help is greatly appreciated.
Athrus
 
Posts: 3
Joined: Tue Jul 21, 2009 7:09 pm

Postby richardk » Wed Jul 22, 2009 10:01 am

What happens? Does the wrong file load? Do you get a 404 error?

Try
Code: Select all
    Options +FollowSymLinks -MultiViews

    RewriteEngine On

    RewriteCond %{ENV:REDIRECT_STATUS} !^$ [OR]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule .* - [L]

    RewriteRule ^/quote/([a-z0-9-]+)/?$ /quote.php?package=$1 [L]
    RewriteRule ^/clients/?$ /soon.php [L]
    RewriteRule ^/([^/]+)/$ /$1.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Athrus » Wed Jul 22, 2009 1:20 pm

host.ca/quote/jkl goes to host.ca/quote.php instead of host.ca/quote.php?package=jkl

postfix: /var/srv/www/_default/quote.php -> /var/srv/www/_default/quote.php/lite
prefix: /var/srv/www/_default/quote.php/lite -> quote.php/lite
applying pattern '.*' to uri 'quote.php/lite'

Also, if i add "Options +FollowSymLinks -MultiViews " everything stops working :S
Athrus
 
Posts: 3
Joined: Tue Jul 21, 2009 7:09 pm

Postby richardk » Wed Jul 22, 2009 3:55 pm

What happens when you go to /clients (with your original mod_rewrite)?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Athrus » Wed Jul 22, 2009 7:07 pm

it goes to soon.php
Athrus
 
Posts: 3
Joined: Tue Jul 21, 2009 7:09 pm

Postby richardk » Thu Jul 23, 2009 9:22 am

If you change
Code: Select all
^/quote/

to
Code: Select all
^/quote2/

does it work? It sounds like a conflict with MultiViews.

Also, if i add "Options +FollowSymLinks -MultiViews " everything stops working :S

Everything? Do you get a 500 error? Even /clients stops working?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 35 guests

cron