I've looked on SO but wasn't able to find the answer to my issue.
How can I go from :
localhost/profile.php?id=22
to:
localhost/charlie
Charlie would be the username (not the first name) here.
I also want to make sure that whether a user types in
localhost/profile.php?id=22
or
localhost/charlie
they get redirected to the appropriate profile they're looking for.
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 /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+profile\.php\?id=22\s [NC]
RewriteRule ^ /charlie? [R=302,L]
RewriteRule ^charlie/?$ /profile.php?id=22 [NC,L,QSA]
Related
I didn' try anything.
But i want to clear one question.
I have a link www.abc.com/meeting/
Is it possible to rewrite abc to my own words
eg: www.myown.com/meeting/
Is it possible with URL rewriting
This is the dynamic version which will redirect all the url to specified domain. So www.abc.com/* will be redirected to www.myown.com/*
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.abc.com/.$ [NC]
RewriteRule ^(.*)$ http://www.myown.com/$1 [R=301,L]
Make sure your Apache have enabled option Rewrite mode
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^abc.com/meeting/.*$ http://www.myown.com/meeting/ [R=301,L]
Use this code in filename as .htaccess save this file in your root folder
allow .htaccess file in your server. In xampp it bydefault activated
I ask your help because I would like to do soms URL rewritting.
Here is the htacess file I wrote for my site
# Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
RewriteBase /
Options +FollowSymlinks
Options -Indexes
php_flag display_errors off
RewriteEngine on
RewriteRule ^helper/?$ index.php?action=helper [NC,L]
RewriteRule ^probabilite/?$ index.php?action=proba [NC,L]
RewriteRule ^demon/?$ index.php?action=demon [NC,L]
RewriteRule ^info/([[:digit:]]+)$ index.php?action=info&competence=$1 [NC,L,QSA]
The host I use is hostinger.fr but I don't know how to use the rewriteRules on it. (They said that it is activated and the first line (RewriteBase /) must be here)
Thanks for your help.
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 would like to rename, not redirect a number of URL's I have on my website using the .htaccess file:
from http://siteaddress.com/?chapter=1 to http://siteaddress.com/about.
As I'm quite new to dabbling with the .htaccess file and I can't afford to brake anything, how would I be able to achieve this in a safe and simple manor?
Thank you.
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 /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+\?chapter=1\s [NC]
RewriteRule ^ /about? [R=302,L]
RewriteRule ^about/?$ /?chapter=1 [L,NC,QSA]
With above in place now when you try to visit http://site.com/about it will internally forward your request to: http://site.com/?chapter=1 while not changing the URL in the browser (no redirect). When you visit http://site.com/?chapter=1 it will be externally redirected to http://site.com/about .
I have a problem i.e suppose the url is www.example.com/view.php?id=1 but I want the url is like that www.example.com/view/id/1 , seperately I get htaccess for hide extension or replace '?' by slash but both are not working please anybody help me .I want .htaccess working for both(extension hide and replace slash) and please make it general that is htaccess working for any page not any particular page.thanks in advance
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 /
# external redirect from /view.php?id=1 to /view/id/1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+([^.]+)\.php\?([^=]+)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [L,R=301]
# internal forward from /view/id/1 to /view.php?id=1
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [L,QSA]