LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > How do I make mod_rewrite suppress processing more rules?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2012, 04:41 AM
adhp123 adhp123 is offline
New Member
 
Join Date: Apr 2012
Posts: 5
Default How do I make mod_rewrite suppress processing more rules?

Given my current .htaccess file, how would I modify it to check for an additional URL path like '/src/pub/' and rewrite it to '/' without affecting the current rewrite? Wordpress
Here's the original .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

and here's my recent attempt (which doesn't work):

RewriteEngine on
Apache
RewriteRule ^/src/pub/(.*)$ /$1 [R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

Edit: Here are some examples of what I want to accomplish:

New Additional Rule:

From: http://www.mysite.com/src/pub/validfile.php
To: http://www.mysite.com/validfile.php

From: http://www.mysite.com/src/pub/user/detail/testuser
To: http://www.mysite.com/user/detail/testuser

Existing Rule (already working):
Mysql
From: http://www.mysite.com/user/detail/testuser
To: http://www.mysite.com/index.php?rout...etail/testuser

I'm guessing that the problem is that the URL is being rewritten by the first rule, and then rewritten again by the second Php.

The solution to that is to add the "last" flag to the first rule, like this:

RewriteRule ^/src/pub/(.*)$ /$1 [R,L]

within a .htaccess file, use this instead:

RewriteRule ^src/pub/(.*)$ /$1 [R]

the leading "/" will not match within .htaccess, only within httpd.conf (src - bottom of page) if you wish for processing of further rules to stop, then add the L flag:

RewriteRule ^src/pub/(.*)$ /$1 [L,R]

rewrite log comparison (.htaccess context):

// using ^/src/pub/(.*)$ - leading slash will not work in .htaccess context!
(1) pass through /home/test/src

// using ^src/pub/(.*)$
(2) rewrite 'src/pub/testme' -> '/testme'
(2) explicitly forcing redirect with http://test/testme
(1) escaping http://test/testme for redirect
(1) redirect to http://test/testme [REDIRECT/302]

Last edited by adhp123; 04-24-2012 at 04:58 AM..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:49 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.