PHP Developers Network
http://forums.devnetwork.net/

htaccess Rewrite not working for Joomla site
http://forums.devnetwork.net/viewtopic.php?f=14&t=137267
Page 1 of 1

Author:  jeff888 [ Mon Jan 14, 2013 4:12 pm ]
Post subject:  htaccess Rewrite not working for Joomla site

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.

Author:  requinix [ Mon Jan 14, 2013 9:20 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site

Try without the RewriteCond.

Author:  jeff888 [ Tue Jan 15, 2013 11:43 am ]
Post subject:  Re: htaccess Rewrite not working for Joomla site


Author:  requinix [ Tue Jan 15, 2013 3:50 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site

...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.

Author:  jeff888 [ Wed Jan 16, 2013 3:13 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site

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]

Author:  requinix [ Wed Jan 16, 2013 3:32 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site

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"?

Author:  jeff888 [ Wed Jan 16, 2013 4:14 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site


Author:  Ad!13 [ Wed Apr 01, 2015 10:50 pm ]
Post subject:  Re: htaccess Rewrite not working for Joomla site

I have the same problem in RewriteCond. I tried removing it. But does not work.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/