I know this question may have been asked many times before and I may be down-voted a lot but trust me, this was my last resort after testing and reading many articles on google.
I have the url /index.php?action=gametypes&mode=control-point
which I would like to rewrite to /gametypes/control-point
.
I've tried
RewriteEngine On
RewriteRule ^gametypes/([^/\.]+)/?$ index.php?action=gametypes&mode=$1[L]
Now when I visit /gametypes/control-point
I get a 404 not found and the URL shows rewrites to localhost/thecoremc/gametypes/control-point/index.php
. It's a 404 because there is no index.php. Any idea what I could use to successfully load the page?
Extra info: I'm running my localhost with the domain localhost/thecoremc/
and apache 2.4.4
Thanks!
You could try this instead...
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?action=$1&mode=$2 [L]
I used a dummy-domain, which was http://www.domain.com/index.php?action=gametypes&mode=control-point to achieve this.
Based on your comment, try this...
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /thecoremc/index.php?action=$1&mode=$2 [L]
which is based on: http://localhost/thecoremc/index.php?action=gametypes&mode=control-point
You can use this code in your /thecoremc/.htaccess
file:
RewriteEngine On
RewriteBase /thecoremc/
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&mode=$2 [L,QSA]
Try this. This might be helpful for your work.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)&name=(.*)$
RewriteRule ^articles\.php$ /article/%1/%2? [R=301]
RewriteRule ^article/([^-]+)/([^-]+)$ /articles.php?article_id=$1&article_name=$2 [L]
The above code will redirect
localhost/a1/articles.php?id=10&name=xyz
to
localhost/article/10/xyz
Try this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule gametypes/(.*)/(.*)/ index.php?action=$1&mode=$2