I am trying to write the following .htaccess
RewriteRule ^follower/([A-Za-z0-9-]+)/?$ follower.php?username=$1 [NC,L]
But it executing like follower.php/?username=example , So my page CSS getting problem .. Total layout getting disturbed !
Any solution to this problem ?
Thanks in advance
Escape your slashes
RewriteRule ^follower\/([A-Za-z0-9-]+)\/?$ follower.php?username=$1 [NC,L]
Related
I have a simple .htaccess:
RewriteEngine on
RewriteRule ^/locations/$ location.php
The folder "mydomain.com/locations/" does not exist but the locations.php does.
According to the hoster the module mode_rewrite is enabled on the server by default but still my rewrite rule won't work.
The request "mydomain.com/locations/" answers with 404.
What am I doing wrong?
Thanks in advance for the help :)
RewriteRule uses a relative path starting without a leading slash on htaccess context . So remove the slash
RewriteEngine on
RewriteRule ^locations/$ location.php
I just learnt about url-rewrite for my website with .htacess. My actual url is:
localhost/index.php?view=some-page
So i write this RewriteRule like this:
RewriteRule ^/([^/]*)/?$ /index.php?view=$1 [NC,L]
When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.
Many thanks
This should work in your DocumentRoot/.htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?view=$1 [QSA,L]
Leading slash is not matched in htaccess.
are you using apache?
This link from step 6 helped me
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
When i was playing around with rewrites i had to enable it and tell apache where the pages were stored
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.
my pages on may site working perfectly until someone puts in the browser smothing like
service.php/service.php . the page does not show any error , just an empty page. I would ht-access to redirect the user to service.php.
thanks for the help
jeff
Adding the following to your .htaccess should work if you can use mod_rewrite.
RewriteEngine On
RewriteBase /base/path
RewriteRule ^.*$ service.php
I am trying to rewrite URLs ending like (not only exactly equal to) this:
comments/The-Latest-Out-of-Pakistan/68
into URLs ending in this:
comments/index.php?submissionid=68
Below is what I have in the .htaccess file, but it's not working.
RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9-]+)/([0-9]+)?$ comments/index.php?submissionid=$2 [NC,L]
Any idea why it's not working?
Thanks in advance,
John
I think the only issue is that you've not escaped the hyphen in the character class [A-Za-z0-9-]+, try replacing it with this [A-Za-z0-9\-]+ and see if that works. If not, we can work from there.
I tested it and this one works:
RewriteEngine On
RewriteRule ^comments/([a-zA-Z0-9-]+)/([0-9]+)?$ comments/index.php?id=$2 [NC,L]