URL rewrite not working -htaccess - .htaccess

I want to rewrite my site URL structure to a SEO friendly url using htaccess file.
I want to rewrite this URL:
/Site/mysite/tags.php?tag=tag
to
/Site/mysite/tags/tag
This is my script:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /tag/(.*)\.php tags.php?tag=$1
other commands such as DirectoryIndex working properly but my above code not.
i know this question asked before but i can not fix this problem. excuse me please!
thanks.

Your script would rewrite /tag/foo.php to tags.php?tag=foo. What you need is
RewriteRule ^/tag/(.*) /tags.php?tag=$1

Try this code rather :
RewriteEngine on
RewriteRule ^Site/mysite/tag/(.*)$ /Site/mysite/tags.php?tag=$1

Related

SEO Friendly URL (with .htaccess)

I would like to add friendly URL's to my website. But I have one problem. I've never used .htaccess.
My link:
https://example.com/index.php?page=users
I would like to have an URL like this:
https://example.com/page/users
OR
https://example.com/users
Is there anyone who can help me?
Problem is solved with:
.htaccess:
RewriteEngine On
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
So it is very simple.

.htaccess rewrite rule mod_rewrite

I have a URL:
http://localhost/sample/custom blog/controllers/sample.php
and I am trying to rewrite it to look like:
http://localhost/sample/custom blog/sample/
I have tried the following but it doesn't seem to work out.
RewriteEngine On
RewriteRule ^custom Blog/([0-9a-zA-Z]+)/(.*) $2 [L]
This to my knowledge should get me at least like this:
http://localhost/sample/custom blog/sample.php
Please help me with this.
And also if you could let me know where I can learn the basics of htaccess, I 'll be delighted.
Thanks.
Place this code in /sample/.htaccess:
RewriteEngine On
RewriteBase /sample/
RewriteRule "^(custom Blog)/([0-9a-zA-Z]+)/$" $1/controllers/$2.php [L,NC]
Make sure there is no .htaccess in custom Blog/ folder.
Reference: Apache mod_rewrite Introduction
Apache mod_rewrite Technical Details

mod_rewrite not rewriting url with a subdomain and folder

I'm starting to learn mod_rewrite and experiencing a problem that I can't solve myself.
I have an url: http://abc.domain.com/en/page.php?id=1
which I want to rewrite to http://abc.domain.com/en/1 when a customer visits it.
I've tried something like this
RewriteRule ^([0-9]*)/$ /vacancies.php?id=$1
but it doesn't really work. I believe the problem is with path as my site located on subdomain(abc) and in folder(en)
I would really appreciate pointing me to the right direction.
Use this in your abc.domain.com/en/.htaccess
RewriteEngine On
RewriteBase /en/
RewriteRule ^([0-9]+)/?$ vacancies.php?id=$1 [NC,L,QSA]

.htaccess question: http://www.example.com/contact should show http://www.example.com/contact.php (without redirecting)

As said in the Title,I want that http://www.example.com/contact should show http://www.example.com/contact.php. And important: without redirecting.
Unfortunately my .htaccess Code does not work:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^contact$ contact.php [L]
What could be the reason for this? Please help me out how to fix it :(!
EDIT: SOLVED. Google helped me out.
Adding Options -Multiviews was the Solution. Thanks everyone!
I do believe you have to put the / at the beginning of contact because it's part of the path.
Try this:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/contact$ contact.php [L]
The only way to make the URL at the top show .php when going to the URL without PHP would be to redirect the browser to it. The easiest way to do that in most apache instances would be:
Redirect permanent /contact http://example.com/contact.php

magento mod rewrite not working help wanted(htaccess) :)

my situation.....
i have this url http://www.example.com/index.php/category?catid=3
i want to have this rewritten to
http://www.example.com/bikes/3
my rewrites on the website are enabled....so i have nice urls on the website for the products
the pages i want to be rewritten are my own modules for pages with text
i have put this in my htaccess
RewriteRule .* index.php [L]
RewriteRule ^bikes/(\.*)/$ category?catid=$1
i have tried about any thing like 1000 combinations but nothing seem to work also i checked if my htaccess is working but it does.First line works also redirect to google works.
Hope someone is able to tell me what i am doing wrong here?
I had this example around here, and I think you can work it out to your needs:
Pretty URL: /topic-41/favourite-cheese.html
Ugly URL: /viewtopic.php?t=41
.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^topic-([0-9]+)/[A-Z0-9_-]+.html$ /viewtopic.php?t=$1 [NC,L]

Resources