I want to rewrite these .htaccess rules into a templates to use it for my other pages as well:
RewriteRule ^admin/add-news/?$ admin/add_news.php [L] RewriteRule ^admin/edit-news/([0-9a-z-@._]+)/([0-9]+)/?$ admin/edit_news.php?name=$1&id=$2 [L] For example:
RewriteRule ^admin/([a-z-])/?$ admin/$1.php [L] RewriteRule ^admin/([a-z-])/([0-9a-z-@._]+)/([0-9]+)/?$ admin/$1.php?name=$2&id=$3 [L] I tested the latest rules on WAMP and it does not work. It returns: 404 Not Found error
The requested URL was not found on this server.
The full .htaccess:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^admin/add-news/?$ admin/add_news.php [L] RewriteRule ^admin/edit-news/([0-9a-z-@._]+)/([0-9]+)/?$ admin/edit_news.php?name=$1&id=$2 [L] Files locations are:
1. C:\wamp64\www\test.com 2. C:\wamp64\www\test.com\admin\add_news.php C:\wamp64\www\test.com\admin\edit_news.php 3. I want redirect from URLs with underscores to hyphens, for example: from admin/add_news.php to admin/add-news Also from admin/edit_news.php?name=%1&id=%2 to admin/edit-news/name/id Example: admin/edit-news/my-news-title/2 Any ideas how to fix it? Thank you.
1. C:\wamp64\www\test.com2. C:\wamp64\www\test.com\admin\add_news.php C:\wamp64\www\test.com\admin\edit_news.php3. I want redirect from URLs with underscores to hyphens, for example: from admin/add_news.php to admin/add-news Also from admin/edit_news.php?name=%1&id=%2 to admin/edit-news/name/idThank you.admin/edit-news/name/idin browser? If yes then please do add this all information in your question to make it more clear, thank you.admin/edit-news/my-news-title/2.