I have a htaccess-file like the following:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?$1=$1&pid=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ /index.php?pid=$1 [L,QSA]
which directs links like fe "administration/modules" to "index.php/administration=administration&pid=modules" or "administration" to "index.php?pid=administration".
For Performance-Reasons, i would like to modify the htaccess, so it can direct a link like
"administration_55"
to
index.php?pid=55"
so the '55' (the id of the record) would have to get extracted somehow from the pid-parameter "pid=administration_55". As i also would like to have a visible url like "www.example.com/administration" without the "_55" part with it, i wonder, how this would be accomplished in a good way, directly in the htaccess file or in the responding php-file with a header redirect?
Thanx in Advance, Jayden
# e.g. /administration/modules
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?$1=$1&pid=$2 [L,QSA]
# e.g. /administration_55
RewriteRule ^([^/]+)_([[0-9]+)/?$ /index.php?$1=$1&pid=$2 [L,QSA]
# e.g. /test
RewriteRule ^([^/]+)/?$ /index.php?pid=$1 [L,QSA]
As for removing the 55, the best way is to use PHP. I have a separate field called 'url' in my database-table, so I can find the record with the correct url(-part). I also added a Index to this field, for performance.
Just because you can doesn't mean you should... Can't you handle this in the index.php of the site itself based on the REFERRER
additionally which would be more secure and not require the .htaccess support to be enabled...?
You can redirect using htaccess but you must have url with _55 part with it