I'm trying to change all http://www.mysite.com/filename.php files to show as http://www.mysite.com/filename/ using mod_rewrite, but I seem to be doing something wrong.
Can anyone help out? I'm guessing it's something pretty simple for those that know. Thanks.
An awesome, simple, copy, paste style tutorial
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
Try this:
RewriteEngine On
RewriteRule ^(.+)\.php$ $1/ [L,QSA]
Related
What is the problem with my .htaccess
This Works:
RewriteRule ^ressource\.n\.1/ /lesson [L,R=permanent]
But this, don't work. I don't know why.
RewriteRule ^index.php?id=51$ /file/?id=51 [L,R=permanent]
I just want when a visitor hit https://www.example.com/index.php?id=51 is going to https://www.example.com/file/?id=51
Thank you!
Okay, so I here .htaccess redirect is a pretty big deal, but I dont know how to do it. Honestly I'm a n00b, so can someone tell me how this is even accomplished? So far I know you have to have a page called
example.com/example.html
and then you want it to look like this:
example.com/example/
My problem is, how do you do that?
That can be achieved by adding the following to your htaccess
RewriteEngine On
RewriteRule ^(.*).html$ /$1/ [R,L]
The above will change any page with a html extension to FILEANME/
I hope someone can help me, I am looking to help an ex-client with some troubles.
they have images from URL's with this sub-sub structure:
http://images.abc1234.SPECIFIC-DOMAIN.com/image.jpg
Due to a long story I do not completely understand, that sub sub structure exists and now is in peril.
Can anyone point to a solution to rewrite the above into:
http://images.ANOTHER-DOMAIN.com/image.jpg
which would also NOT AFFECT something like this:
images.THIRD-DOMAIN.com/image.jpg
Any help to this challenge would be appreciated.
Thank you and sorry if this is written in bad form, it's not my area of expertise.
this will redirect:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^images.abc1234.SPECIFIC-DOMAIN.com$ [NC]
RewriteRule ^(.*\.(jpg|png|gif))$ http://images.ANOTHER-DOMAIN.com/$1 [L,R=301]
I've looked online and couldn't find exactly what I was looking. I tried to combine two different tutorials together but still nothing.
I need an .htaccess rule that changes:
game.php?id=$1&title=$2
to
/game/$1/$2.html
I've gotten it to work with one word as $2 but if there is a space, everything crashed. My current code is
RewriteEngine on
RewriteRule ^game/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ game.php?id=$1&title=$2
Any help will be greatly appreciated.
Thanks,
It looks like your wrote the opposite of what you are asking for. Currently your rewrite will rewrite
/game/$1/$2.html to game.php?id=$1&title=$2
RewriteRule ^game/([^/]+)/([^/]+)/?$ /game.php?id=$1&title=$2 [L]
if you are wanting the other way like you asked it'd look like this:
RewriteCond %{QUERY_STRING} ^id=(.*?)&title=(.*?)$
RewriteRule ^game.php$ /game/%1/%2.html? [L]
If it's only about spaces try adding "\s" to square brackets:
RewriteRule ^game/([A-Za-z0-9-\s]+)/([A-Za-z0-9-\s]+)/?$ game.php?id=$1&title=$2
I have the following entry in my .htaccess file:
RewriteRule ^blogs$ ?name=data&case=gview&group_id=31%1 [L]
What I do is, I redirect blogs to ?name=data&case=gview&group_id=31
Now what happens is, all my urls are now blogs?id=1 etc, but I need them to stay just ?id=1
How can I remove the blogs from rest of the urls?
This what I came up with, but it doesn't work:
RewriteRule ^blogs?(.*)$ /$1 [L]
EDIT I might be explaining it wrong. I need to change the actual url display of the links. Is that actually possible?
Not sure... but is that what you're looking for ?
RewriteRule ^/?$ /blogs [L,QSA]
What's wrong with just adding a R to your original rule?
RewriteRule ^blogs$ ?name=data&case=gview&group_id=31%1 [L,R=301]
Ok, the answer is pretty much: It can't be done. I just went over my code, added / before main urls and all is working as intended.
Thank you both for suggestions.