htaccess Rewrite not working for Joomla site

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
jeff888
Forum Newbie
Posts: 4
Joined: Mon Jan 14, 2013 2:54 pm

htaccess Rewrite not working for Joomla site

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: htaccess Rewrite not working for Joomla site

Post by requinix »

Try without the RewriteCond.
jeff888
Forum Newbie
Posts: 4
Joined: Mon Jan 14, 2013 2:54 pm

Re: htaccess Rewrite not working for Joomla site

Post by jeff888 »

requinix wrote:Try without the RewriteCond.
Thanks for the reply. That didn't work. I actually tried initially without the condition
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: htaccess Rewrite not working for Joomla site

Post 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.
jeff888
Forum Newbie
Posts: 4
Joined: Mon Jan 14, 2013 2:54 pm

Re: htaccess Rewrite not working for Joomla site

Post 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]
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: htaccess Rewrite not working for Joomla site

Post 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"?
jeff888
Forum Newbie
Posts: 4
Joined: Mon Jan 14, 2013 2:54 pm

Re: htaccess Rewrite not working for Joomla site

Post 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
Ad!13
Forum Newbie
Posts: 2
Joined: Wed Apr 01, 2015 10:35 pm

Re: htaccess Rewrite not working for Joomla site

Post by Ad!13 »

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