PHP - Moved: Help With Re-writing Urls (mod_rewrite) In .htaccess
This topic has been moved to mod_rewrite.
http://www.phpfreaks.com/forums/index.php?topic=357656.0 Similar TutorialsThis topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=355043.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321843.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=323272.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359560.0 Hello everybody,
I am honestly quite a newb when it comes to mod_rewrite.
We run a small social media page with different areas and I would like to change the URLs to something more clean and professional.
User profiles look like this:
http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477siteid 59 is the artists list and the keyid at the end is the ID of the artist but should be like: http://www.sky-mp3.com/mischuraor in worse case like: http://www.sky-mp3.com/user/mischuraCMS pages look like this: http://www.sky-mp3.com/index.php?siteid=106but should be like: http://www.sky-mp3.com/charts(page name instead of siteid) What I know so far: - I have to add something to the .htaccess file - I need to change something in the code (but I don`t know where) Im good he? What would be the first step on the path to clean URLs for me? I found alot of infos here and there but found nothing yet for this specific case. Kind regards from and thx in advance from Cologne I'm currently runing an classifieds ads site, Php + Mysql (no frameworks) Basically i have the ads listing page (ads.php) and the ads details page (ad_detail.php)
This is my current .htaccess:
# disable directory browsing Options All -Indexes ErrorDocument 400 /error.php ErrorDocument 401 /error.php ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php ErrorDocument 502 /error.php ErrorDocument 504 /error.php RewriteEngine on RewriteRule ^(.*)-da([0-9]+)$ ad_detail.php?ad=$2 RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^([^\.]+)$ $1.php [NC,L]The final result is something like this: www.mysite.com/this-is-the-ad-detail-da50555 (the number is the ad id) What i need is to get this: www.mysite.com/ads/another-ad-detail-da50777 + What can i do in others urls to show like www.mysite.com/about/ instead of www.mysite.com/about (without the /) I already tried this but doesn't work: RewriteEngine on RewriteBase / RewriteRule -da([0-9]+)/?$ ad_detail.php?ad=$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] RewriteRule ^(.+?)/?$ $1.php [L] Edited by asanti, 22 November 2014 - 05:16 PM. About a year ago I wrote a mod_rewrite in at sites htaccess file. It was to call a page that queried the database based on a unite code that was assigned to a member. If the member was assigned a code that was FL1001, the URL www.marketingteammates.com/FL1001 would bring up a page that quaried that member and displayed their database content.
In the users table of the site, it quaried the field webPageID and the information was called. It called a page webpage.php that quaried the info. The URL in the address bar still displayed www.marketingteammates.com/FL1001. Here are the lines of code in the htaccess file.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z])([A-Za-z])([0-9]+)$ /webpage.php?webPageID=$1$2$3 [NC,L]I now have a second page completely different from the webpage.php. It is a page storeNumber.php and would query a field storeNumberID. This field could contain any kind of string such as Store#101, or mystore101, or #101 is my store. I tried using the same rewite rule just replaceing the webpage.php and variable with storeNumber.php and $storeNumberID. This doesn't work. It also leads me to wonder if there can even be two different pages in the mod_rewrite. How would it diferentiate one from the other. Thanks for any help in advance. Mike This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357809.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=309061.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=308956.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=328210.0 This topic has been $verb->toPastTense() to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=354538.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356538.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359558.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=329079.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=326189.0 This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=333684.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=349238.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356252.0 This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=306351.0 |