?
Solved

mod_rewrite - strange output

Posted on 2012-08-20
3
Medium Priority
?
593 Views
Last Modified: 2012-08-22
On a site using mod_rewrite I'm experiencing some strange output.

The main site are using the .htaccess file below, to rewrite url's - works fine...

But the subfolder /admin seems to inherit the rewrite behaviour even though this is not wanted - how can I stop this ?

RewriteEngine on
RewriteBase /
 
# Directories to ignore
RewriteRule ^(assets|inc|cms|css|images|img|admin|js|topimages|video)(/.*)?$ - [L]
RewriteRule ^(index\.php)$ - [L]  
RewriteRule ^(mod_redirect\.php) - [L]
RewriteRule ^(balule_mail\.php) - [L]
RewriteRule ^(login\.php) - [L]  

RewriteRule ^(.*)(\.html)$ mod_redirect.php?url=$1$2 [L]
RewriteRule ^([^/]*)/([^/]*)/?$     index.php?lang=$1&url=$2  [NC]
RewriteRule ^([^/]*)/?$    index.php?url=$1  [NC]

In /admin I have a file "login.php" - and it seems like every time I request that file, the server also streams the index file from the main site ?!?

So basicly, I'm looking for a way to stop the inheritance from the parent folders .htaccess file, is that even possible ??

Best regards,
Mark
0
Comment
Question by:internetservice_dk
3 Comments
 
LVL 26

Expert Comment

by:arober11
ID: 38311535
Stick a .htaccess file in the admin directory with a:

RewriteEngine off
0
 
LVL 9

Accepted Solution

by:
Erdinç Güngör Çorbacı earned 2000 total points
ID: 38314330
Disabling rewrite rules for the directories you wish to exclude is simple.
Just add this line to the root  .htaccess  as the first rule.

You won't need to create a .htaccess for every directory (less file to control)

# to not use rewriting rules for the directory admin
RewriteRule admin/ - [L]

Open in new window



your new .htaccess file ;

RewriteEngine on
RewriteBase /
 
# Directories to ignore
RewriteRule admin/ - [L]
RewriteRule ^(assets|inc|cms|css|images|img|admin|js|topimages|video)(/.*)?$ - [L]
RewriteRule ^(index\.php)$ - [L]  
RewriteRule ^(mod_redirect\.php) - [L] 
RewriteRule ^(balule_mail\.php) - [L]
RewriteRule ^(login\.php) - [L]  

RewriteRule ^(.*)(\.html)$ mod_redirect.php?url=$1$2 [L]
RewriteRule ^([^/]*)/([^/]*)/?$     index.php?lang=$1&url=$2  [NC] 
RewriteRule ^([^/]*)/?$    index.php?url=$1  [NC]

Open in new window

0
 

Author Closing Comment

by:internetservice_dk
ID: 38319376
Right to the point :)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question