I want to manipulate the URLs in my site. For example, I want to rewrite this URL profile/anything/about to profile/anything but it not just working, it shows my Page Not Found constructed page, here is my .htaccess file
ErrorDocument 404 /pageNotFound.php
<IfModule mod_rewrite.so>
Option +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^profile/(.*)/about profile/$1/index.php [NC,L]
</IfModule>
Please help me out, am new to this
I don't really see anything bad in your code but it didn't work for me also, but here is the trick. If "L" is included among your flags just make sure that the next line is commented. It worked for me.
And I think you should use the match any of contents = [] instead of any character
ErrorDocument 404 /pageNotFound.php
<IfModule mod_rewrite.so>
Option +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^profile/([0-9a-zA-Z]+)/about profile/$1/index.php [NC,L]
#this is a commented line after the LAST RULE flag
</IfModule>
Related
I know many user have asked this question but i have tried everything still not understand the problem
I have url like this
http://localhost/test/storelocator.php?page=store
Now i want to like this
http://localhost/spawake/storelocator
My htaccess
# Turn Rewrite Engine On
RewriteEngine on
# Rewrite for storelocator.php
RewriteRule ^storelocator storelocator.php [NC, L]
but showing me the error in all the pages Internal Server Error So anyone can plz hep
Remove space after NC
Disable MultiViews option
Restrict your pattern by using end anchor.
Your .htaccess:
Option -MultiViews
RewriteEngine on
RewriteBase /spawake/fbdemo/
# Rewrite for storelocator.php
RewriteRule ^storelocator/?$ storelocator.php [NC,L]
The URL can be in the format of either:
http://www.example.com/subdomain/123456 or http://www.example.com/123456
I need to rewrite it to:
http://www.example.com/content_pages.php?page=about_us&refferal=123456
I'm using:
RewriteRule ^(/?\w*/?)(\d{4,10})$ $1content_pages.php?page=about_us&refferal=$2 [NC,L]
It works on then online RegEx tester. But gives 404 error on the actual site. Pleaes help.
Try this code instead:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+/)?(\d{4,10})/?$ /$1content_pages.php?page=about_us&refferal=$2 [L,QSA]
I have a URL:
www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space
I want to stay on the same page above but simply display the URL in the address bar like this:
www.example.com/property-listings/united-states/colorado/denver/office-space
How do I accomplish this using htaccess and rewrite rules?
If I understood right, try writing a rule like this one:
RewriteEngine on
RewriteRule property-listings/united-states/colorado/denver/office-space http://www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space [L]
OK. You didn't supply a pattern or mentioned there was any, so I have to guess the pattern is up to /denver/ subdirectory. Try this:
RewriteEngine on
RewriteRule ^(property-listings/united-states/colorado/denver/)(office-space)/?$ $1denver-co-$2 [L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(property-listings/united-states/colorado)/(denver)/(office-space)/?$ $1/$2/$2-co-$3 [L,NC]
Can any check given code of .htaccess file and let me know what's wrong with it and why it's not working?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^itinerary/([a-zA-Z0-9_-]+)/([0-9]+)\$ itinerary-details.php?tId=$2
I want to rewrite url as below:
www.domain.com/itinerary-details.php?tId=2&tName=agra-delhi-tour
to
www.domain.com/itinerary/2/agra-delhi-tour
and
www.domain.com/itinerary-details.php?page=1&tId=2&tName=agra-delhi-tour
to
www.domain.com/itinerary/2/agra-delhi-tour/1
Please help me in doing this.
Thanks
Seems that you have the two sections in your regex reversed. This should work for both your cases:
^itinerary/([0-9]+)/([a-zA-Z0-9_-]+)/?(.*) itinerary-details.php?tId=$1&tName=$2&page=$3
I also just noticed that you were escaping the $ which would also cause problems.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^itinerary/([^/]+)/([^/]+)/?$ /itinerary-details.php?tId=$1&tName=$2 [L,QSA,NC]
RewriteRule ^itinerary/([^/]+)/([^/]+)/([^/]+)/?$ /itinerary-details.php?page=$3&tId=$1&tName=$2 [L,QSA,NC]
Ok I have a script in the folder 'intake'. The index.php file auto creates a list of urls. Those urls are in the format:
/intake/4/Westrop
I have an .htaccess file in the intake folder. I want it to redirect the url to a FILE.
The above example would then become /intake/redirect.php?id=4&name=Westrop
Here's what I have so far:
DirectoryIndex index.php
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/(.*)$ /intake/redirect.php?id=$1&name=$2 [L]
</IfModule>
But for some reason if I type /intake or /intake/index.php I get a 404 error. According to firebug its trying to take "intake" and turn it into "intake.php"
Any ideas?
Place the following code in .htaccess file in website root folder:
RewriteEngine On
RewriteRule ^intake/(\d+)/([a-z0-9\-_]+)$ /intake/redirect.php?id=$1&name=$2 [NC,QSA,L]
P.S.
Do not use this sort of pattern -- ^(.*)/(.*)$ -- in your case for longer URLs it will work not as you would expect. It will match your URL .. but in a wrong way.
Start your .htaccess with this option:
Options +All -MultiViews -Indexes