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]
Related
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.
Hi So I am trying to remove includes/pagesfrom a url that looks like http://localhost:8888/london/includes/pages/soho-london-guide/ For local dev. I am using MAMP and I've enabled mod_rewrite too.
So far I've been trying to use different techniques and here is a list of what I've been using (trying to make it work :((( )
RewriteEngine ON
RewriteRule ^includes/pages/(.*)$ $1 [L,QSA]
Also
RewriteEngine on
RewriteBase /
RewriteRule ^/includes/pages/(.+)$ /$1 [L,QSA]
Very very new to .htaccess and regex syntax so any help would be appreciated.
Have this rule in your site root .htaccess:
RewriteEngine on
RewriteBase /
RewriteRule ^([\w-]+)/(?!includes/pages/)(.+)$ $1/includes/pages/$2 [L,NC]
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'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 am using Wamp server that is localhost is my server and "mysite" is my site folder name in WWW direcotry
Here is my URL
..../mysite/videos/show.php?id=535&category=books
want this
......./mysite/videos/show/id/category
My .htacces code is:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^videos/show/(.*)/(.*)$ /videos/show.php?id=$1&category=$2
But it is not working any help...
I had the same problem 1 month ago. I found the answer thanks #anubhava. He`s suggestion work perfectly for me give it a try i hope to help you.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+videos/show\.php\?id=([^&\s]+)&category=([^&\s]+) [NC]
RewriteRule ^ /videos/show/%1/%2? [R=301,L]
RewriteRule ^videos/show/([^/]+)/([^/]+)/?$ /videos/show.php?id=$1&category=$2 [L,QSA,NC]
Try something like this:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /mysite
RewriteRule ^videos/show/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ /videos/show.php?id=$1&category=$2
And Check mod-rewrite module of apache must be enable. If not than enable it and restart your server again.