robj Posted June 9, 2009 Share Posted June 9, 2009 I'm attempting to rewrite the following: /test,name.php to /test Here's the short story: The files are being generated by a different department and are automatically placed on the server. There are 2 parts to the file name. The first is the type of data (which will always be different), and the second is the time/date/version/revision#/ stamp. The parts are currently being separated by a comma, but could be changed to a hyphen or period (underscore is cannot be used unless it's possible to define the last underscore as the separator). I only want to display the first part of the file name, and preferably drop the .php extension. Example: http://www.MYURL.com/first_name,123456789.php would read http://www.MYURL.com/first_name My current .htaccess file: RewriteEngine On RewriteBase / # Externally redirect direct client requests for .php files to non-.php URLs RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/ RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.MYURL.com/$1 [R=301,L] # # Internally rewrite extensionless page URLs to PHP files # if no extension or trailing slash on requested URL RewriteCond %{REQUEST_URI} !(\.¦/$) # and if filename exists when .php is appended RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule (.+) /$1.php [L] I've tried quite a few attempts without getting close. I'm not as skilled with apache as I'd like (hence the notes) The above works perfect, but I need help with remove the comma and everything past it. All help and ideas are appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/161541-rewrite-rule-comma-separated/ Share on other sites More sharing options...
dreamwest Posted June 12, 2009 Share Posted June 12, 2009 it would be easier to have the url http://www.MYURL.com/first_name.php?id=123456789 RewriteRule ^name/(.*) first_name.php?id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/161541-rewrite-rule-comma-separated/#findComment-854308 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.