Forum Moderators: phranque

Message Too Old, No Replies

Having trouble understanding Apache redirect rule I need to use

         

stuffedmonkey

9:42 am on May 15, 2012 (gmt 0)

10+ Year Member



Hi everyone,

I'm having a little trouble understanding if re-directs is even what I need here. Basically I'm using a CMS which auto generates "area" pages however, in order to get some benefit from the SE's for my choosen site theme / keywords I want to basically show a different URL to my visitors and to the SE's. The URL generated currently gives me no such benefit and doesn't really match the theme of my site.

The current URL looks like this:

http://www.example.com/area/boston/

And I am trying to make it display like this:

http://www.example.com/parks/boston/


Thank-you for any help you can give me

[edited by: incrediBILL at 10:01 am (utc) on May 15, 2012]
[edit reason] fixed URLS, use Example.com [/edit]

incrediBILL

10:10 am on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you have any sample code you're currently trying that does a redirect?

Basically you want to match URLs with "area/" and redirect to "parks/".

Take a shot a making rule if you haven't already and let us take a look, lots of samples in this very forum, As a matter of fact, exactly what you need comes up almost daily.

Even more important, to help match your theme, what color is your current .htaccess file?

lucy24

8:19 pm on May 15, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm having a little trouble understanding if re-directs is even what I need here.

There exist problems that can't be solved with mod_rewrite. But there are not many. Wouldn't it be fun to rewrite yourself so your children or employees-- or parents or employers-- think you're in one place when you're really somewhere else entirely? What you probably want is a Redirect followed by a Rewrite. There are ... well, no time to count, but I'm guessing 8,000 earlier posts in the Apache forum spelling it all out.

I want to basically show a different URL to my visitors and to the SE's

:: bzzt! danger! bzzt! danger! ::

stuffedmonkey

9:04 am on May 16, 2012 (gmt 0)

10+ Year Member



Thank-you incrediBILL. Perhaps I'm missing something but I assumed a URL rewite would simply change the URL in the browser but anything I try returns a 404 error. This is what I'm trying:

RewriteRule ^area/boston/?$ parks/boston/ [NC]

Which leads me to believe that what I am looking to do can't be done. I don't want to redirect to a new or even a different page - just display a different URL for the current page. The only reasons I want to do this is to make my URL's more user friendly, make it easier for my users to share the URL's and to hopefuly gain some benefit for having my main keyword in the URL. Unfortunately the module I am using for the joomla CMS is no longer supported so rather that try to find someone who could modify it for me, I thought some form of URL redirect / rewrite would work and would be easier.

@ Lucy. Thank-you for your helpful post. I guess there is always one

lucy24

11:48 am on May 16, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I assumed a URL rewite would simply change the URL in the browser

Backward. A rewrite changes the content of a page without changing the displayed URL. The only way to change the address bar is to redirect. And then, once the address bar shows the pretty URL that you want people to see, you can quietly rewrite them so they're seeing the content you want them to see.

Do a Forums search for rewrite + redirect + boilerplate. It's been posted a few times.

g1smd

10:58 pm on May 16, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I assumed a URL rewite would simply change the URL in the browser

No. Mod_rewrite cannot make or change URLs.

You start by first linking from the pages of your site to the URL that you want users to see and use, such as href="/this".

Once the link is clicked, the browser requests that URL from the server and then mod_rewrite can do its stuff.

RewriteRule ^this /that.php [L]


When example.com/this is requested, fetch /that.php from the server and show the content of that file but without revealing the name of that file.

You'll also need another RewriteRule, this time configured as a redirect. This is so that when the user requests example.com/that.php they are told by way of a redirect to make a new request for example.com/this instead.