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
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]
I created a site and make its URL seo friendly like www.mywebsite.com/home.
but actual homepage is in my /SomeFolder/index.php which is rewrite its url to /home.
Now i want to set /home url as a default page in htaccess file. But when i set this.
DirectoryIndex /home
I got the 500 error. One way is to give the redirection in index.php so it will redirect me to the /home page. but i think its a weird method.
Is there any other way??
Thanks
Remove that DirectoryIndex line.
You'll need this rule in your DocumentRoot/.htaccess:
RewriteEngine on
RewriteRule ^home/?$ /SomeFolder/index.php [L,NC]
this best article for create pretty URLs :
http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/
Try DirectoryIndex home/index.php
use this one , hope this will helpful for you
Options +FollowSymLinks
RewriteEngine on
RewriteRule home(.*)\$ index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/somefolder
RewriteRule ^(.*)$ /somefolder/$1 [L]
src: https://www.siteground.com/kb/how_to_change_my_document_root_folder_using_an_htaccess_file/
Although I have entered an issue so I have an open question, which might be worth monitoring. I will update if I figure it out myself which I aim to do.
.htaccess make sub dir home dir but force www and https whilst maintaining links
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'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]
I need to redirect a page like this:
http://example.com/clients/themes?domain=localhost.com
this link should be redirected to skin.php which is in the same directory.
Can any one help me? 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 %{QUERY_STRING} ^domain=localhost\.com$ [NC]
RewriteRule ^clients/themes/?$ clients/skin.php? [L,NC]
This will internally forward your request to /clients/skin.php stripping out query string. If you want query string as well then remove ? after skin.php.