![]() |
Need Help With URL Manipulations.
Hello All,
I decided to try and play around with directives/parameters you can place within .htaccess within a directory on a web hosting server. I am looking to do the following and really have no clue (after looking through the vast amount of sites online) what to really use (since I am not sure what I am looking for). This is what I would like to accomplish: Change This: http://www.mydomain.com/index.php?pg=home To This: http://www.mydomain.com/home Obviously, the modified URL will act just like the original link so that I can easily use the pg variable within my code (since I have a few checks on the variable "pg"). Also, continuing with this same concept, would it be easy to pass multiple variables within the same URL (example: http://www.mydomain.com/index.php?pg=home&cmd=do)? Any help would greatly be appreciated. Thanks in advance!:) -SlickVic78 |
I ended up finding out how to do what I wanted to do with this URL manipulation. Instead of doing the folder structure, I decided to go the file structure route. Both can easily be accomplished writing a few lines to the .htaccess of the folder you want to apply this to.
So far things are working very well. Woot! :) -SlickVic78 |
Can you post the code please. ;)
|
Hello war59312,
Sure thing. All it requires is a few lines within your .htaccess file and you are good to go. Suppose you have a URL that looks like this: To manipulate your URLs, simply add this code to your .htaccess file: Code:
RewriteEngine On So you would use this URL instead: [EDIT] Removed ".php" after catalog. [/EDIT] You would then have to be sure that all your URLs on your page reflect the new URL format, and you should then be good to go. If you would prefer the Folder Structure like: Let me know and I'll be more than happy to share my findings. -SlickVic78 |
Yea that would be great too. ;)
Thanks a ton, Will PS: Bet this helps with google too. ;) |
Quote:
It should help with all search engines. Google started indexing variables within the URL, but to play it on the safe side, it wouldn't hurt to use this method. Please take note of the edit above. I had to correct the URL you would use if you were to apply the code in my last post. Here is the code to place within you .htaccess if you want the folder structure. Remember though - since the URL is being re-written, your images may break because of the folder structure. I will comment on that later. Here is the code you would place in the .htaccess if you were to want folder structure URL manipulation: Code:
RewriteEngine On Now, the way to fix the image breakage, there are 2 ways:
Code:
RewriteRule ^.+(images|scripts)/(.*)$ /$1/$2 [L] If you do not modify this, you will end up with this as an example: Where it should be: Also, if you have more than 9 variable pairs (&something=something) within your URL and are running apache >1.3.28 or >2.0.45, you may want to add this line within your .htaccess: Code:
RewriteOptions MaxRedirects=25 All this I learned from Robert over at http://forum.modrewrite.com/. This guy was totally helpful and has gotten back to me with every question I threw at him. I hope this helps you out Will as much as it did for me! :) Enjoy! -SlickVic78 |
Heck yea, thanks a ton. :)
|
All times are GMT +1. The time now is 04:35 AM. |
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.