PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 23, 2017 1:13 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Jan 14, 2013 4:12 pm 
Offline
Forum Newbie

Joined: Mon Jan 14, 2013 3:54 pm
Posts: 4
Hi,

I'm having trouble getting my RewriteCond and RewriteRule to work properly. All i need to do is rewrite a rule for just one URL. I want "index.php/locations/maryland/self-storage-baltimore-md" to be "maryland/self-storage-baltimore-md" .The bolded area below is what I added. I've checked many sources and it seems to be correct. Yet, when I save the file and go check the URL, it's still showing the former URL. Not sure what I'm doing wrong here

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
RewriteBase /

RewriteCond %{REQUEST_URI} ^index.php/locations/maryland/self-storage-baltimore-md [NC]
RewriteRule ^maryland/self-storage-baltimore-md$ index.php/locations/maryland/self-storage-baltimore-md[L]

# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.


Top
 Profile  
 
PostPosted: Mon Jan 14, 2013 9:20 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6573
Location: WA, USA
Try without the RewriteCond.


Top
 Profile  
 
PostPosted: Tue Jan 15, 2013 11:43 am 
Offline
Forum Newbie

Joined: Mon Jan 14, 2013 3:54 pm
Posts: 4
requinix wrote:
Try without the RewriteCond.


Thanks for the reply. That didn't work. I actually tried initially without the condition


Top
 Profile  
 
PostPosted: Tue Jan 15, 2013 3:50 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6573
Location: WA, USA
...You're expecting the URL to change? You need a [R] flag to force mod_rewrite to actually redirect you, otherwise it'll just do the redirection behind the scenes.

Otherwise if you're going to exactly "/maryland/self-storage-baltimore-md" then I don't know why you're not seeing the "index.php/locations/maryland/self-storage-baltimore-md" page.


Top
 Profile  
 
PostPosted: Wed Jan 16, 2013 3:13 pm 
Offline
Forum Newbie

Joined: Mon Jan 14, 2013 3:54 pm
Posts: 4
I was able to removed the index.php/ portion out of the url but not locations/. When I try to do so, I get a 404 error page
Here's my updated rule.

RewriteRule ^index.php/locations/maryland/self-storage-baltimore-md locations/maryland/self-storage-baltimore-md [R]


Top
 Profile  
 
PostPosted: Wed Jan 16, 2013 3:32 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6573
Location: WA, USA
So you're going to "index.php/locations/maryland/self-storage-baltimore-md" and expecting to be redirected to "locations/maryland/self-storage-baltimore-md"?


Top
 Profile  
 
PostPosted: Wed Jan 16, 2013 4:14 pm 
Offline
Forum Newbie

Joined: Mon Jan 14, 2013 3:54 pm
Posts: 4
requinix wrote:
So you're going to "index.php/locations/maryland/self-storage-baltimore-md" and expecting to be redirected to "locations/maryland/self-storage-baltimore-md"?


Right. And so far it is doing that now, except I can't seem to be redirected to maryland/self-storage-baltimore-md which takes me to a 404 error page


Top
 Profile  
 
PostPosted: Wed Apr 01, 2015 10:50 pm 
Offline
Forum Newbie

Joined: Wed Apr 01, 2015 10:35 pm
Posts: 2
I have the same problem in RewriteCond. I tried removing it. But does not work.

_________________
Ada


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group