PHP - Moved: Freindly Urls With Php And Htaccess
This topic has been moved to mod_rewrite.
http://www.phpfreaks.com/forums/index.php?topic=323272.0 Similar TutorialsThis topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359560.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357656.0 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. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=326189.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=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 mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=318730.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 Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=306351.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=314407.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=357878.0 This topic has been rewritten to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356324.0 (have I used that one before? I need to write these down somewhere) This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=349451.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=333386.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=306379.0 This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=342523.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=342235.0 This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=310649.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=353241.0 |