Space Pirate
Join Date: May 2004
Location: Atlanta
|
I recently made the mental leap to understanding how to serve up URLs to mod_rewrite so that I have pretty URLs in some of my simple websites.
I need some help though, when it comes to using a 301 Redirect to 'clean up' the URL when people hit the website from an old PHP-encrusted link. For example: Suppose that someone clicks an old-fashioned URL to our site, and that the page still exists at: Code:
example.com/index.php?x=foo but we want it to look like this:Code:
example.com/foo in their browser's navigation bar, as it does when clicked upon from any navigation links internal to this website.I thought that using a redirect in this fashion: Code:
Redirect 301 /index.php?x=foo http://example.com/foo would work just fine, but of course it does not. Any insight you folks could provide would be appreciated. ... |
quote |
Lord of the Rant.
Formerly turtle2472 Join Date: Mar 2005
Location: Upstate South Carolina
|
Shouldn't it be a rewrite rule? I'm not great to .htaccess but this seems like what it should be.
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule> This is for WP that makes the index.php go away. It's going to be more like this.Louis L'Amour, “To make democracy work, we must be a nation of participants, not simply observers. One who does not vote has no right to complain.” Visit our archived Minecraft world! | Maybe someday I'll proof read, until then deal with it. |
quote |
Lord of the Rant.
Formerly turtle2472 Join Date: Mar 2005
Location: Upstate South Carolina
|
This site says to do this:
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /x/(.*) index.php?x=$1 Though you might want to remove the "/x" to fit your request. |
quote |
Space Pirate
Join Date: May 2004
Location: Atlanta
|
Oh now I've got the rewrite working, that part is EASY....
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/?([a-zA-Z_0-9\s]+)$ index.php?x=$1 [L] It's the redirect of a specific "old-fashioned" link that I'm wanting to fix. I don't even want the visitor to end up SEEING the ugly PHP code, even if they clicked such a link. ... |
quote |
Posting Rules | Navigation |
|
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need a redirect page | turtle | Programmer's Nook | 3 | 2009-06-07 18:33 |
Redirect non-www traffic to www? | turtle | Programmer's Nook | 3 | 2008-11-09 16:15 |
Garbage in Google's "Sponsored Links". Wtf? | Brad | General Discussion | 8 | 2008-08-04 12:41 |
Microsoft code garbage? | alexluft | Third-Party Products | 10 | 2005-04-28 10:05 |
PHP & Apache 2 | ast3r3x | Genius Bar | 0 | 2005-03-16 20:38 |