htaccess rewrite rule with PHP GET variables causing 500 internal error - .htaccess

I've been attempting this: playerstats.php?player=Notch would result in www.example.com/Notch, yet the problem is every method I try it results in a 500 internal server error.
RewriteEngine on
RewriteRule ^([^/]*)\$ playerstats.php?player=$1 [NC,L,QSA]
I'm using NGINX also if thats any concern

Replace your code with this:
RewriteEngine on
RewriteRule ^([^/.]+)/?$ playerstats.php?player=$1 [L,QSA]

Related

URL rewrite for / causing 500 internal server error

I have a rewite rule that should redirect the index page (/) to a different page so I can deal with all of my content in there. However adding this second rule caused a 500 internal server error and I am not sure why.
This is in my .htaccess file
Its the 3rd line:
RewriteEngine on
RewriteRule ^search/(.*)/?$ search.php?postcode=$1
RewriteRule ^(.*)$ /turnstile.php?goto=home [L]
You have to exclude the destination you are rewriting to.
RewriteRule ^((?!turnstile.php).*)$ /turnstile.php?goto=home [L]

.htaccess URL and resources

I have the next url:
www.dude12345.com/section.php?id=5
I want to be like this www.dude12345.com/section/5
I used the next code
Options -MultiViews
RewriteEngine On
# redirect "/section.php?id=xxx" to "/section/xxx"
RewriteCond %{THE_REQUEST} \s/section\.php\?id=([0-9]+)\s [NC]
RewriteRule ^ /section/%1? [R=301,L]
# internally rewrite "/section/xxx" to "/section.php?id=xxx"
RewriteRule ^section/([0-9]+)$ /section.php?id=$1 [L]
It works..my link it looks how i want (www.dude12345.com/section/5).
But i have a problem my resources are not loaded good. In console appear something like: "Failed to load resource: the server responded with a status of 404 (Not Found) www.dude12345/section/images/myimg.png " and it's not ok, need to apear someting like www.dude12345/images/myimg.png. I have no idea how to resolve the problem.
Try this, it is working fine for me.
Just make sure mod_rewrite is enabled.
RewriteEngine On
RewriteRule ^/?section/([^/d]+)/?$ section.php?id=$1 [L,QSA]

Getting Error 500 when trying to use RewriteRule

I am trying to figure out the code to make all my links with no extension to be redirected to a certain page using .htaccess. For example:
http://mysite.com/link
Gets rewritten to:
http://mysite.com/run.php?id=link
I have tried the following code but I receive an Internal Error 500 and can't even access my homepage.
RewriteEngine On
RewriteRule ^([^/]*)$ /run.php?id=$1 [L]
Thanks for your help I think found the answer:
RewriteEngine on
RewriteBase /
RewriteRule ^.htaccess$ - [F]
RewriteRule ^([A-z,0-9,_,-]+)/?$ /run.php?id=$1 [QSA]
This seems to work. Although I'm not soo sure if anything else is affected. The homepage still loads if I type www.mysite.com/index.php so I think it is ok.

500 Internal Server Error in my wamp server while trying to Rewrite URL in .htaccess

I'm trying to rewrite my bulky, ugly url to a neat one which is converting "art.php?id=$1" in to "art/1", but I encounter a "500 Internal Server Error" What shall I do? Can you help me pleeeease?
This is the .htaccess code I used:
RewriteEngine On
RewriteRule ^art/([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
This is the Error I encountered:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request. Please contact the server
administrator, admin#localhost and inform them of the time the error
occurred, and anything you might have done that may have caused the
error. More information about this error may be available in the
server error log.
Thanks!
Supposed everything is in the gallery folder, which itself is located in the www root directory. Then put this .htaccess file into the gallery folder as well
RewriteEngine on
RewriteBase /gallery/
# prevent endless loop
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
# serve real content
RewriteRule ^art/([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
# make pretty URL
RewriteCond %{QUERY_STRING} id=(.+)
RewriteRule ^art.php$ art/%1? [R,NC,L]
Depending on the server you're on, you might want to set the base for rewriting
RewriteEngine On
RewriteBase /art/
RewriteRule ^([A-Za-z0-9-]+)/?$ art.php?id=$1 [NC,L]
that should work just fine

.htaccess RewriteRule giving 500 server error

I have a rewrite rule as follows:
RewriteRule ^equipment /equipment.php [L]
It will throw a 500 server error... but if I were to replace the equipment.php with, for example, our contact page contactUs.php it will redirect to the contact page with no problems.
I have other rewrite rules that work fine - but I can't figure out why this won't work.
Limit your Rule by adding $
RewriteRule ^equipment$ /equipment.php [L]
I found the answer.
I needed to do RewriteRule ^equipment/$ /equipment.php [L]
Thanks all.

Resources