Jump to content

Friendly urls problem with htaccess


asanti

Recommended Posts

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.