I have htaccess with these rules:
RewriteEngine On
rewritecond %{http_host} ^www.example.com [nc]
rewriterule ^(.*)$ http://example.com/$1 [r=301,nc]
RewriteRule ^admin/$ admin.php [L]
RewriteRule ^home/$ index.php [L]
RewriteRule ^news/(.*)-([0-9]+)/$ index.php?p=news&id=$2
My url is:http://example.com/news/why-do-not-you-love-me-1/#main
Test on htaccess.mwl.be, it return http://l2baium.com/index.php?p=news&id=1#main with which works on my site.
But on my side, it still doesn't realize it. I restarted apache2 on my Ubuntu 14.02 three times. But there is no light for it.
Could someone tell me why?
Thanks.
P/s: My system's using php 5.5.x
Sorry for being stupid. But i did not know that i must setup so that Php would parse htaccess file until last night.
Sorry everyone.
Related
I've been crawling forums for about 2 hours and still haven't found the solution to my problem so I am turning to you guys for help.
My URL looks like this
http://sevalinmutfagi.com/list.php?id=1?kategori=borekler
I want it to look like this
http://sevalinmutfagi.com/tarifler/borekler
I try so much rewrite example but my index file at a subfolder in /View/ so I can't rewrite my URLs
here my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?sevalinmutfagi.com$ [NC]
RewriteCond %{REQUEST_URI} !^/View/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /View/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?sevalinmutfagi.com$ [NC]
RewriteRule ^(/)?$ View/index.php [L]
This code works well for redirect subfolder all pages but I try to add rewrite URL codes can't work. I hope that has been revealing. Thanks to every for help.
that's worked for me fine.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/subfolder
RewriteRule ^(.*)$ /subfolder/$1 [NC,L]
The FIRST thing to learn about mod_rewrite is when NOT to use it. Since mod_alias handles your specific task very nicely, that’s what I’d use:
Redirect 301 / /subfolder/
Since that looks like it would be “loopy,” you could fall back on mod_rewrite:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^subfolder/
RewriteRule .? subfolder%{REQUEST_URI} [R=301,L]
There’s just too much wrong with your attempt to cover … and I’ve addressed exactly those issues many times in many threads. Therefore, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too
I have a perfectly working website working as the root of my webhost (/public_html), but I recently bought a new domain and parked it there too, so I needed a subdir for it (/public_html/newdomaindir).
Now I need to move my entire website to a subfolder (/public_html/website) and I'm having a hard time adapting the .htaccess files.
This was my old working .htaccess file when it was root:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.org$
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L]
#SetEnvIfNoCase Host ^www\.website\.org$ require_auth=true
RewriteCond $1 !^(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer)
RewriteRule ^(.+)$ /index.php?/$1[L,QSA]
And now the webhost support suggest that I have this .htaccess file as root, to redirect traffic.
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} website.org$
RewriteCond %{REQUEST_URI} !website/
RewriteRule ^(.*)$ website/$1
But, well... it's not working as expected. My website is broken.
Should I use a different approach, maybe ask the support guys to change the document_root of my website? Should I change anything in the subfolder .htaccess file?
Any help is greatly appreciated. Thanks.
Not my strongest skill, but I would try to modify your previous .htaccess to following form:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.org$
RewriteRule ^/?$ "http\:\/\/www\.website\.org\/" [R=301,L]
# not sure what about this
#RewriteCond $1 !^website\/(index\.php|images|css|robots\.txt|js|icons|files|fonts|extplorer)
RewriteRule ^$ website/ [L]
RewriteRule ^(.+)$ website/index.php?/$1[L,QSA]
If this does not work, maybe you will find some clues in this SO answer.
i have already search for a long time and i could not figure our why Rewrite Rule is not working. i want to translate this url
http://localhost/uniwood/template-allgemein.html?postname=kontakt&pageid=27
to
http://localhost/postname/kontakt.html
here the code in the htaccess file
RewriteEngine On
RewriteRule ^postname/([^/]*)\.html$ /uniwood/template-allgemein.html?postname=$1&pageid=27 [L]
I'am using locally on my machine the mamp pro webserver and checked that AllowOverride is on "all".
I do not get any mistakes! Also no error logs!
thanks!
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} /template-allgemein\.html\?postname=([^\s&]+)&pageid=27 [NC]
RewriteRule ^ /postname/%1.html? [R=302,L,NE]
RewriteRule ^postname/[^.]+)\.html$ /template-allgemein.html?postname=$1&pageid=27 [L,NC,QSA]
I'm running Windows 7 xampp server it has Apache and it has lines that are needed to uncomment to work fine.
However when I try to use RewriteRule I bump into the problem.
When I write wrong code at the start of htaccess it throws error 500, there are few commands that works, but when I use RewriteRule it simply ignore that part , unless if I write something syntax wise wrong then it reacts as error, but i have never seen my link changed.
.htaccess file is placed at myDomain directory
Can it possibly be issue of software or it's my code?
I have this dynamic link:
http://localhost//myDomain/folder/ad.php?title=theTitle&id=1
and I need to get this:
http://localhost//myDomain/folder/theTitle/1
My htaccess file looks like this:
RewriteEngine on
RewriteBase /myDomain/folder
RewriteCond %{REQUEST_URI} ^/ad.php$ [NC]
RewriteCond %{QUERY_STRING} ^title=(.*)&id=(.*)$
RewriteRule (.*) http://localhost/myDomain/folder/%1/%2.aspx? [R=301,L]
Any help would be highly honored :)
You can have these rules in /myDomain/folder/.htaccess:
RewriteEngine on
RewriteBase /myDomain/folder/
RewriteCond %{THE_REQUEST} /ad\.php\?title=([^\s&]+)&id=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L]
RewriteRule ^([^/.]+)/([0-9]+)/?$ ad.php?title=$1&id=$2 [L,QSA]
I hope all of you are having a great week!
I have moved a code ignite site to a new server, When I moved it across I tested it here.
http://31.25.190.77/~freelanc
Where it works perfectly, so then I pointed the domain name at it.
http://www.freelanceentrysolutions.co.uk/
but not it doesn't work! Only the homepage works but if I click another link I get
Not Found
The requested URL /supply-and-installations.html was not found on this
server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Any ideas here?
Kind Regards, Brad
SOLVED
I added this to the HTACCESS
RewriteEngine On
RewriteCond %{HTTP_HOST} ^freelanceentrysolutions\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.freelanceentrysolutions\.co.uk$
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule (.*) /index.php/$1
It work perfectly with http://www.freelanceentrysolutions.co.uk/index.php/supply-and-installations.html !
i think the 'index.php/supply-and-installations.html' is problematic.
You might need to put index.php in all of your links?
/index.php/supply-and-installations.html
Try
http://www.freelanceentrysolutions.co.uk/index.php/supply-and-installations.html
or rewrite URLs to achieve this without using index.php
MODIFICATIONS:
If you are on apache put following in a .htaccess file and put that in root folder.
RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Another good version is located here:
http://snipplr.com/view/5966/codeigniter-htaccess/
SOLVED! I added this to my HTAccess file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^freelanceentrysolutions\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.freelanceentrysolutions\.co.uk$
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule (.*) /index.php/$1