how to rewrite url using htaccess - .htaccess

https://example.in/mesurements/index/booking/
something like
https://example.in/booking/
Someone help Me

To do this, you can add the following lines to your .htaccess file in the document root folder:
RewriteEngine On
RewriteRule ^booking/(.*)$ /mesurements/index/booking/$1

Related

htaccess redirect from folder with subdirectory to single path directoy

Previously my site was in wordpress, now converted into html.
I have 500+ pdfs that needs to redirect from
mysite.com/wp-content/themes/my-theme/pdfs folder to mysite.com/pdf/
Do you have server-level access to the site? If so I would create a symbolic link in the public root directory of your website to wp-content/themes/my-theme/pdfs and call it pdf.
If all you can do is .htaccess, then you can create a file like this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^pdf/(.*)$ /wp-content/themes/my-theme/pdfs /$1 [R=301,NC,L]
You might check out a great tutorial on rewrite rules.
I tried like this it works for me.
RewriteRule ^wp-content/themes/my-theme/pdfs/(.*)$ /pdf/$1 [R=301,NC,L]

URL rewrite not working -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

Redirect subfolder index.php to subfolder root

I have the following url I want redirect using the .htaccess file in root with Mod Rewrite. I have searched and found good examples for the index file in root, but not in subfolder.
This is what I have and what I need.
Thank you in advance for your help.
/folder1/index.php
/folder1/index.php/
to
http://www.example.com/folder1/
/folder2/index.php
/folder2/index.php/
to
http://www.example.com/folder2/
I was asked for only 2 hyperlinks so I removed part of the link on the examples above. I appreciate the shorter way because I have many folders.
Try this in your .htaccess file.
RewriteEngine On
Rewrite ^/folder1/index.php$ /folder1/ [L]
<Directory folder1>
DirectoryIndex index.php
</Directory>
Of course the index can be what every you want like newindex.php.
To redirect /folder/index.php to /folder ,You can use :
RewriteEngine on
RewriteRule ^([^/]+)/index\.php$ /$1/ [NC,L,R]
This will redirect :
/anyfolder/index.php
to
/anyfolder/

.htaccess Rewrite URL as subdirectory

I have this url:
http://mysite.com/home.php?name=username
I want to be able to access that by going to:
http://mysite.com/home/username
Is there a way to do that?
You can do this using the mod_rewrite extention that comes with Apache.
Create a new .htaccess file in your web root directory, and populate it with the following text.
RewriteEngine On
RewriteRule ^home/([^/]*)$ home.php?name=$1 [L]

How to create htaccess fiel in api link

I created API by using PHP.
My API link is
http://localhost/phpworkspace/api_testing/api.php
I want to clean my API link by using .htaccess file like
http://localhost/api/v1/retrieve.json
I created various htaccess file. But I can't get. How can I do that? Please help me kindly.
Create .htaccess file in your www directory and paste the following code into the .htaccess file
RewriteEngine On
RewriteRule ^api/v1/retrieve\.json$ /phpworkspace/api_testing/api.php [L]
This ought to do what you want
RewriteEngine On
RewriteRule ^api/v1/retrieve.json$ /phpworkspace/api_testing/api.php [NC]
step 1 : On rewrite mod
step 2 : put code in .htaccess file
.htaccess file
RewriteEngine On
RewriteBase /api_testing
RewriteRule ^api/([.*]+)/$ /api_testing/api.php [L,QSA]

Resources