I want every file on my server like this
"mywebsite.com/video?id=vgIjgt863_53",
I have php so at the moment it would look like this
"mywebsite.com/video.php?id=(id)"
I need this in htaccess
Put your htaccess in root folder with this code
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^video$ /video.php?id=%1 [L]
Related
am working on making my site urls search engine friendly and for which am rewriting urls with GET parameters and so i have done rewriting but now htaccess is not pointing that url to php file which is suppose to handle the url
my old url
www.domain.com/foo/myfile.php?nid=554
new rewritten url with php
www.domain.com/foo/554-demo-page-title
my current htaccess rules which work for old urls but not for new
Options +FollowSymLinks
RewriteEngine On
#RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteCond %{SCRIPT_FILENAME} !-f
RewriteBase /
RewriteRule ^([0-9]+)-(.*) ./foo/myfile.php?nid=$1 [NC]
so i want to that both old and new urls land on /foo/myfile.php becuase myfile.php can handle both urls incase of old url it rewrite and redirect as new url , i played for few hours with htaccess rules but no success
You can use this rule in site root .htaccess (assuming there is .htaccess inside foo/ directory):
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^foo/(\d+)-.*$ foo/myfile.php [L,QSA,NC]
If you already have /foo/.htaccess then use this rule inside that file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /foo/
RewriteRule ^(\d+)-.*$ myfile.php [L,QSA]
All my site url reads
http://example.com/myfolder/main/other/extra/index.php
I want it to rewritten as
http://example.com/index.php
Try the below rule :
Options +FollowSymlinks
RewriteEngine on
rewriterule ^myfolder/main/other/extra/index.php(.*)$ http://example.com/index.php$1 [r=301,nc]
I need to make redirections from a sub-directory to the parent directory.
In other words I have to redirect anything matching
http://exemple.com/portfolio/product1
to :
http://exemple.com/product1
Is there any way to do that with URL REWRITE ?
Thanks
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 ^portfolio/(.*)$ /$1 [L,R=301,NC]
You want to put this into .htaccess inside the directory that you want to be redirrected
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/parent
RewriteRule ^(.*)?$ http://%{HTTP_HOST}/parent
I'm new in .htaccess file. i m searching on net but i m not able to change and rewrite URL in PHP...
E.G
Show URL Like :
localhost/web/site/view_project.php?vp=14
I want show my URL like
localhost/web/site/project/14/
In php i m use this code
href="view_project.php?vp=<?php echo $c_id>" echo $c_project_title
In .htaccess file I'm using
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^project/([0-9]+)/?$ /view_project.php?vp=1& [L,R]
Now please tell what need to change in PHP Code and HTACCESS file... I'm totally new in this.
Change your PHP code to this:
href="project/<?php echo $c_id>" echo $c_project_title
And then 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 ^project/([0-9]+)/?$ /view_project.php?vp=$1 [L,QSA,NC]
You need to use $1 instead of 1 as you have it now, for more see here: https://serverfault.com/questions/389684/how-can-i-store-request-uri-in-a-variable-manipulate-it-and-then-use-it-in
I'm try to rewrite my url
http://www.domain.com/live/randomword
it should go rewrite to
http://www.domain.com/live/?cat=randomword
here are my tests:
RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1
and all i have in the htaccess file is:
RewriteEngine on
You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:
RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]
If this still doesn't work be sure to check that mod_rewrite is enabled
also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.
hope this help
Have this code in your .htaccess file:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]
in rewrite rule the file name or extension in missing?
write rule like,
RewriteRule ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1