X
X
Xrist1An2015-02-23 08:28:56
Apache HTTP Server
Xrist1An, 2015-02-23 08:28:56

How to make an exception in mod_rewrite?

I have the following instruction in .htaccess: Simply put, I direct all site.com/sometext requests to site.com/page.php?s=sometext But if I have a directory called "sometext" in the root of the site, then the redirect will work on a crooked url: site.com/sometext/?s=sometext How can I write exceptions for one or two directories?
RewriteRule ^([A-Za-z0-9-]+)$ page.php?s=$1 [PT]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2015-02-23
@IvanG

The line below is inserted before the RewriteRule and allows you not to process the address value starting with /res/
You can write the second directory in the same form below, and so for all exception options, or tie regexps.

S
ShamblerR, 2015-02-24
@ShamblerR

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)$ page.php?s=$1 [PT]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question