I'm a newbie in writing .htaccess file and even after 3 hours of tutorial, I still can't achieve what I want...
Hope you could help me :) ! :
FIRST I need to redirect my website http://www.runnincity.com to http://www.runnincity.world
To do so, I wrote a .htaccess file located to the root of runnincity.com with the code :
Redirect permanent / http://www.runnincity.world/
This is fine.
THEN I need http://www.runnincity.com/blog to be reachable through the URL http://www.runnincity.world/blog but I don't want the rewriting to be visible for the user. So if the user write http://www.runnincity.world/blog, the URL must stay as it is but display the content of www.runnincity.com/blog .
I wrote a new .htaccess located in the root of runnincity.world with the code below (but doesn't work) :
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^runnincity.world/blog$ runnincity.com/blog [P]
I feel completely lost ... thanks for your help !
Related
I wrote the following codes with .htaccess
RewriteRule ^articles/([0-9a-zA-Z-_]+)$ page.php?article_seolink=$1 [NC,NE,L]
And I created the following URL address
example.com/articles/article-title
But I want to create a link like
example.com/article-title
How can I do this and redirect old URL to new one?
With your shown samples, please try following rules. Please make sure to place your htaccess Rules file inside articles folder. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^([0-9a-zA-Z-_]+)$ page.php?article_seolink=$1 [NC,NE,L]
I'm going to try and make this as simple as possible, I have a POST form that sends information called $searchid, I want to redirect it to look like a directory
I want to take the following information: (Server, folder, file, post)
localhost/shorts/profile.php?searchid=12345
And I want to make it look like (Server, fakefolder(id), fakefolder(post))
localhost/id/12345/
Also, is there A way to incorporate the sitename, as all the htaccess ive seen before hasnt had it and it's been showing the entire path from C drive.
In htaccess in the root :
RewriteEngine on
RewriteRule ^id/([0-9]+)/?$ /sports/profile.php?searchid=$1 [NC,L]
This will rewrite
/id/numbers
to
/sports/profile.php?searchid=numbers
and allow you to access the page /sports/profile.php?searchid=numbers using the clean url /id/numbers .
I am struggling with an age old problem. I inherited a site with some pretty good SEO and one glaring problem. The entire site is hosted on the /site/ subdirectory. I have decided that I need to load the site at the root. So something like http://example.org/site/index.php will instead redirect to /index.php (<-- that counted as a link, if it is unclear I mean it to be the root of the site/index.php.)
We use joomla for our backend and there are hundreds of pages on the site at this point. I have struggled getting any of the redirects I have seen to do what I want them to do. Basically, any page our patrons visit from an old link with /site/ in it should be redirected to the exact same link, but without the star.
I am open to just loading the page from /site/ and making it look like it is from root. It is my understanding that this can be done with some advances mod-rewrite (http://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs ?) but I have not had any success yet. I run a beta site that mimics the parent site in a subdomain that I have already moved from /site/ to / so I can test a lot of .htaccess configs.
Any help is appreciated... thanks!
Just to be sure: you want http://example.org/site/foo/bar/baz.php to go to http://example.org/foo/bar/baz.php, that is, to remove (via redirect) the /site prefix if it's there, but not touch the URL otherwise, right? If so, it depends on which server you're using:
If your server is Apache, you could use something like this in .htaccess:
RedirectMatch 301 ^/site/(.*)$ http://example.com/$1
If it is nginx, add this to the server {...} session of your site's file (usually symlinked inside /etc/nginx/sites-enabled):
location ~ ^/site/(.*)$ { rewrite ^/site/(.*)$ /$1 permanent; }
Here is a good explanation on how such pattern-based redirects can be set up in both servers.
This seems to be the working answer that I will go with. Basically, this needs put into the directory that you are wanting to redirect from, in my case, that was root/site/.
RewriteEngine on
RewriteCond %{http_host} !^www.beta.example.org$ [nc]
RewriteRule ^(.*)$ http://beta.example.org/$1 [r=301,nc,L]
I assume the first rule ignores www? I'd love to work around that but am not sure exactly why it would have been created anyway. this will rewrite any URL that accesses that .htaccess file (inside your subdirectory) and direct you to the same URL without the subdirectory listing. It doesn't really work with the index.php rewrite tool, but that is fine because it still reaches the correct page.
If anyone has a better option for me with use with Joomla I would be glad to hear it. But, I tihnk this is what I will go with for now because it is giving me great results.
if your server is apache2, you can configure there
<VirtualHost *:80>
ServerName sitio.com
ServerAlias www.sitio.com
DocumentRoot /home/user/public_html/sitio/
...
</VirtualHost>
You need permissions for this change
I'm trying to redirect all links for a site that looks like: www.domain.com/~me to subdomain.newdomain.org/. I only have access to the .htaccess file under my subfolder on domain.com and not the root .htaccess file. I can get it so that I redirect links like www.domain.com/~me/page2.html to the root subdomain.newdomain.org or to subdomain.newdomain.org/~me/page2.html, but I can't figure out how to get to subdomain.newdomain.com/page2.html. Any help would be greatly appreciated. (Ideally the user would still see www.domain.com/~me, but this is not entirely necessary.)
You must select the part after ~me in a capture group and append that to your new domain
RewriteEngine On
RewriteRule ^~me/(.+) http://subdomain.newdomain.org/$1 [L]
Just building a site using php. I would like to know how to create pages without having to make ".php" links for every page. For example I want to build the site to be as follows: www.mysite.com/products instead of www.mysite.com/products.php. (Further example www.mysite.com/products/headphones )
An example of what I am looking for is as follows: http://www.starbucks.ca/store-locator
Any idea how starbucks is doing this? It isn't making a separate folder and index for every page is it?
Thanks in advance!
Jason
You can use URL rewriting to do this. You can create a .htaccess file, place it in the root directory of your website with the following content (as an example):
RewriteEngine On
RewriteRule ^tutorial/([0-9]+)/$ index.php?tutorial=$1
RewriteRule ^page/store-locator/$ index.php?page=store-locator
RewriteRule ^$ index.php
These are some basic rules that tell the web server to rewrite a URL without .php to a URL that does have .php.
In the above example, when you are visiting example.com/tutorial/3/, it will actually visit example.com/index.php?tutorial=3 and then your index.php will display the contents. It's similar for the store-locator page.