Page 1 of 1

htaccess Rewrite not working for Joomla site

Posted: Mon Jan 14, 2013 3:12 pm
by jeff888
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.

Re: htaccess Rewrite not working for Joomla site

Posted: Mon Jan 14, 2013 8:20 pm
by requinix
Try without the RewriteCond.

Re: htaccess Rewrite not working for Joomla site

Posted: Tue Jan 15, 2013 10:43 am
by jeff888
requinix wrote:Try without the RewriteCond.
Thanks for the reply. That didn't work. I actually tried initially without the condition

Re: htaccess Rewrite not working for Joomla site

Posted: Tue Jan 15, 2013 2:50 pm
by requinix
...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.

Re: htaccess Rewrite not working for Joomla site

Posted: Wed Jan 16, 2013 2:13 pm
by jeff888
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]

Re: htaccess Rewrite not working for Joomla site

Posted: Wed Jan 16, 2013 2:32 pm
by requinix
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"?

Re: htaccess Rewrite not working for Joomla site

Posted: Wed Jan 16, 2013 3:14 pm
by jeff888
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

Re: htaccess Rewrite not working for Joomla site

Posted: Wed Apr 01, 2015 10:50 pm
by Ad!13
I have the same problem in RewriteCond. I tried removing it. But does not work.