I've just setup a subdomain for my site.
My problem is:
when I go to http://xyz.site.com I didn't see anything. Only "The link appears to be broken".
But when I go to http://xyz.site.com/index.html all it works fine.
The problem is in .htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^([a-z0-9]+)/?$ profile.php?id=$1 [NC]
If I comment the RewriteRule it works correctly.
How can I fix the htaccess? Maybe with a RewriteCond?
Thanks.
I will set a default page in .htaccess if I were you.
DirectoryIndex index.html
Related
I am a beginner in the REWRITING URL and in fact I replaced this link http://www.downisynet.rf.gd/article.php?id=14 with http://www.downisynet.rf.gd/tutoriel/14
Yet both links are still accessible.
So I want to know how to redirect the old URL to the new one?
Here is my .htaccess code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel-([0-9]+) article.php?tutoriel=$1 [L]
Thank you for helping me!
You can simply 301 redirect one page to another using .htaccess. Add the following to your .htaccess file:
RewriteEngine on
Redirect 301 /article.php?id=14 http://www.downisynet.rf.gd/tutoriel/14
Modified rule for /tutoriel/any-digit to /article.php?tutoriel=any-digit
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel\/([0-9]+)$ /article.php?tutoriel=$1 [L]
I have edited my /etc/hosts file to link domain.com to my localhost. Now when I visited domain.com I want it to get the site contents from domain.com/site/ but only using the URL domain.com thus removing site/ from the URL.
I have done this once before, so I know it's possible, but I lost the code. Can someone please assist me? .htaccess scripting is not my strong. Apologies if this is a duplicate of something else.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!site/).*)$ site/$1 [L,NC]
I have managed to get this working with the following code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)your_directory
RewriteRule ^(.*)$ your_directory/$1 [L]
I try to add the following logic to a .htaccess file:
subdomain.domain.xx make a redirect to subdomain.domain.xx/subdomain/
xy.domain.xy redirect to xy.domain.xy/xy/ (it should work with every subdomain without adding new rewrites)
i found a lot of solutions to redirect subdomain.domain.xx -> domain.xx/subdomain, but nothing like i need... below you find the code i try out.
Hope someone can help me. Thanks.
RewriteEngine on
RewriteBase /
RewriteRule ^([^.?]+[^.?/])$ $1/ [R]
RewriteCond %{HTTP_HOST} ^(www)?.domain.ch/$
RewriteRule .* http\://%1$1.domain.ch/%1$1 [I,R=301]
Place this in the .htaccess file of your subdomain's root directory:
DirectoryIndex index.html
RewriteEngine on
Redirect permanent /index.html http://subdomain.domain.xx/subdomain/
I am working on a project in PHP and using Apache server.
Say, my project's url is myurl.com.
When i visit
http://myurl.com
it works well.
But when I visit
http://www.myurl.com OR www.myurl.com
it redirects me to http://myurl.com, dropping the www subdirectory.
I want it to stay same, like if we visit http://www.myurl.com it should keep the "www" in url.
I believe this is a .htaccess setting.
I couldn't get the settings right.
Please guide
Thanks
You should open the htaccess file and search for something like
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.myurl\.com$ [NC]
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]
This code is redirecting.
Look further here: http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html#m0-askapache2
Looking to put the following into my htaccess file:
User visits http://mysite.com/test/test/123
User is actually visiting http://mysite.com/test/index.php?q=123
I have seen it done before but I can't figure it out. The user is not supposed to see that they are visiting the second url. This is particularly useful for SEO. Can anyone help me on this one?
Updated Code for Answer:
Options -Multiviews
rewriterule ^test\/([a-zA-Z]+)\/([0-9]+)$ test\/index\.php?id=$3 [L]
*Note: The Options -Multiviews is needed for GoDaddy hosting to enable mod_rewrite.*
Be sure mod_rewrite is on:
RewriteEngine on
RewriteRule ^test/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ test.php?id=$2
Double test
RewriteEngine On
RewriteRule ^test/test/([^/]*)$ /test/index.php?q=$1 [L]
Single test
RewriteEngine On
RewriteRule ^test/([^/]*)$ /test/index.php?q=$1 [L]