unable to change url with .htaccess in godaddy hosting - php

I have to change url with .htaccess
.htaccess is stored in link folder.
My .htaccess file is
Options -Multiviews
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([1-9a-z]*)$ index.php\?u=$1 [L]
when i open this
'http://example.com/link/index.php?u=3ujkzf'
url it works.
But when I open
'http://example.com/link/3ujkzf' short link
I got default godaddy hosting error page.
Please Help..
Thank you for Reading..

If your project is located in the link folder, you need to include that:
RewriteRule ^link/([1-9a-z]*)$ /link/index.php?u=$1 [L]
By the way, you don't need to escape the question mark in the second part of the rewrite rule

try adding RewriteBase /
just below RewiteEngine On

Related

How to remove Directory name from the URL using .htaccess for localhost

I want to change the URL from:
http://localhost/rootdirectory/portfolio/project-1.php
To:
http://localhost/rootdirectory/project-1
I have used below code currently but it's not working
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^portfolio/(.*)$ /$1 [L,NC,R=301]
This code is rewriting my URL as http://localhost/project-1 instead of
http://localhost/rootdirectory/project-1.
This code is rewriting my URL as http://localhost/project-1 instead of http://localhost/rootdirectory/project-1.
The code you posted is "redirecting", not "rewriting", the URL from /portfolio/<project> to /<project>.
From your URL example it looks like you should instead be rewriting the URL from /rootdirectory/<project> to /rootdirectory/portfolio/<project>.php (assuming you have already changed the URL in your application). If the .htaccess file is located at /rootdirectory/.htaccess (as stated in comments) then you would need something like the following instead:
RewriteRule ^([^./]+)$ portfolio/$1.php [L]
And remove the RewriteBase / directive altogether.
go to the folder that contains all the files for your site.
form your cpanel copy all the files to your Public_html folder.

Cant redirect my URL with htaccess

I am using WAMP and my url is localhost/hotel/hotels.php?id=21
Using rewrite rule as follow,
Options +FollowSymLinks
RewriteEngine on
RewriteRule hotels/id/(.*)/ hotels.php?id=$1
RewriteRule hotels/id/(.*) hotels.php?id=$1
But nothing happens..
My mod_rewrite is on and also changes done in httpd.conf file.
Please give me a suggestion to handle the issue?
You must use flags for your RewriteRule. You can change it as follow
RewriteEngine on
RewriteRule ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L]
You can call your pages from
localhost/hotel/hotels/id/12
If your .htaccess file is located in localhost/hotel .

Subfolders Url rewriting using htaccess

i am working within sub folder of my website and i want to rewrite my urls.
i have never done this before nor have any knowledge of rewriting rules.
I have a file which named show.php which takes parameter id which is any no and then it echo that no on to the screen.
Now this file is in folder name polo.
www.xyz.com/polo/show.php
i want to rewrite
www.xyz.com/polo/show.php?id=10
to
www.xyz.com/polo/id/10
I tried this answer but still its not working.
Subfolders using htaccess
Any help would be appreciated.
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 ^(polo)/(id)/([0-9]+)/?$ /$1/show.php?$2=$3 [L,QSA,NC]

Trouble with php mod_rewrite

i'm having some mod_rewrite problems. I am working on a rewrite simple rewrite tool that should help me with my website. but i don't know where is the problem
this is my .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule ^text\/$ text.php [L,NC]
and my phpinfo() says that i have my mod_rewrite loaded
also i have a apache hadler: AllowOverride On
so I don't know why this isn't working... can anyone tell me what else could be the problem ?
You need to add the following at the top of your .htaccess file
Options +FollowSymlinks
Also, what rewrites do is allow you to go to
http://www.mydomain.com/text
and see the content that would be generated if you actually went to
http://www.mydomain.com/text.php
rather than the other way around. So the rewrite rules are basically
RewriteRule <what-I-type-in-my-address-bar> <what-page-I-see>

URL Rewrite/Mod Rewrite .htaccess on Apache and PHP

I have a single point of entry on my website
mysite.com/admin/index.php?View=List&Model=User
All access to the DB/application is through this index.php file.
I would like to clean my URL from what is shown above to.
mysite.com/admin/List/User
The idea is to remove the key 'Model and 'View'.
I have found this link that looks very similar.
PHP/Apache: Rewrite rules with .htaccess
in htaccess file insert this code :
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
The rewritten URL:
http://mysite.com/admin/List/User
this site very useful for generate rewrite URL
http://www.generateit.net/mod-rewrite/
Create a file named .htaccess in your web root if you haven't already got one with the following:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
This might work:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
Add to .htaccess in the root folder of your website.

Categories