I can't get this working... I want www.mydomain.com/w.php?watch=12345 to looklike www.mydomain.com/12345 and 12345 can be any number or char. RewriteEngine On RewriteBase / RewriteRule ^(.*)\$ w.php?watch=$1 [L] Not right? I suck at this, to tired to think clear Edit: Some guy gave me this code that worked RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /w.php?watch=$1 [L,QSA] Code (markup):
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/w\.php.* [NC] RewriteRule ^(.+)$ /w.php?watch=$1 [L,QSA] Code (markup):
Hi Everyone, I was hoping if someone can point me to right direction or help me with this problem. I have a forum which has long links, I want them short but don't know where to even begin. Currently this is my link: http://www.sitename.com/directory/nextarticle.php?group=1&offset=0&thread=24099&article=85370 I want to be able to make the link short and instead of thread numbers and article numbers, I wish to have post titles in the links so if the title for the above link is Hello everyone, can you help? I would like to have the link as: http://www.sitename.com/directory/hello-everyone-can-you-help.htm What is the best way to get the browser title in URLs and mod rewrite for this? Thanks in advance!
Hoping someone can get rid of my headache with this. I know its simple but I cant get it right: I had a blog at http://www.domain/oldblog/ and moved it to http://www.domain/newblog/ So ... to redirect from the first to the second I need code in .htaccess in the newblog folder as follows: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /newblog/ RewriteRule ^SOMETHING HERE I CANT GET RIGHT [R=301,L] </IfModule> Any suggestions gratefully received!
I think you had RewriteBase messed up. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^newblog oldblog [R=301,L] </IfModule>
Hi folks, I would appreciate if anyone could give me some help with this. Google indexed a couple of pages with the following URL: http://images.llfk.com/users.php?act=user_gallery&gal=funny-images Code (markup): I would like to use mod_rewrite to tell Google bot to change those old URLs to new ones: RewriteCond %{QUERY_STRING} act=user_gallery RewriteCond %{QUERY_STRING} gal=([^&;]*) RewriteRule ^users\.php$ http://images.llfk.com/gallery/%1/1/? [NC,R=301,L] Code (markup): but then I need the following rule to pass the values to my php script: RewriteRule ^gallery/([^/]+)/([0-9+])/$ http://images.llfk.com/users.php?act=user_gallery&gal=$1&page=$2 [NC] Code (markup): This sends the mod_rewrite running circles and the redirection fails. How to fix this problem? Thanks.
I am using wamp 1.7 When I write this code to the .htaccess file that give error " Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase /b2b/ RewriteRule ^index.html$ index.php " Please help me and tell me , what is wrong in it... Thanks in advance
The rules look fine as you have pasted them. I think we'll need some more information to figure this one out. You've got a tricky one... Firstly, the exact behaviour you see when requesting the first URL (users.php?blah=blah). Use curl --include http://images.llfk.com/users.php?act=user_gallery&gal=funny-images and look at the response code and the redirect URL. We will most likely also want to know what happens when you request the URL that you are being redirected to. The second thing you can do is add these two lines (or something similar) to the .htaccess and have a look at the rewrite log. These logs can get very large very quickly so you'll probably want to turn it off once you have requested the URL once. RewriteLog "/var/log/apache2/rewrite_log" RewriteLogLevel 3 Code (markup): This log will help you figure out exactly which rules are matching which input URLs and why. I'm happy to help interpret the output of both steps if you want to PM them to me. There will be a bit too much data to paste straight into the thread.
Some site www.abadwebsite.com highjacked my website. They are showing a page in their website with content, images and css loaded from my site as www.abadwebsite.com/landing1.php . My website is agoodwebsite.com is getting lots of hits for the css, images file. I tried mod_redirect as per apache guide to prevent the hotlink , but it didn't work.. RewriteRule .*\.()$ - [F,NC] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://agoodwebsite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://agoodwebsite.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://agoodwebsite.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://agoodwebsite.com$ [NC] RewriteRule .*\.(js|css|png)$ - [F,NC] Any help appriciated.. Thomas
Are you sure it's not working ? With those rewrites you will still get the hits in your Apache log but the HTTP status will be 403 Forbidden and the actual content will be an error message rather than the image or css file. If you tested them by visiting the bad site then your site's js, css and png files are all probably cached in your browser so you won't see the changes immediately. Apart from the first line which seems to forbid any file that ends in a full stop, the only other potential problem I can see is that you may not have turned the rewrite engine on. Add RewriteEngine On as the first line and see if that helps.
Hi, I am very new to htaccess so I need just a little help to get me started. If a visitor to my site clicks this link to change to a new region: the real link: http://class.domain.com/index.php?region=245 I would like them to be directed here and only to see this: http://newyork.domain.com There are several region numbers each corresponding to a specific city and I don't actually want to create a subdomain. Any help would be appreciated.
Hi, I've been trying to find info about this but haven't had any luck so far. Most redirect code I have seen are for 301, 404, and subdomains. Anyhow, what I want to achieve is have alternate domains redirect to subfolders of public_html. Here is my unsuccessful code: Options +Indexes Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{http_host} ^fr-domain\.ca [nc] RewriteRule ^(.*)$ http://www.fr-domain.ca/fr/$1 [R=permanent,nc,L] RewriteCond %{http_host} ^fr-domain\.com [nc] RewriteRule ^(.*)$ http://www.fr-domain.com/fr/$1 [R=permanent,nc,L] RewriteCond %{http_host} ^en-domain\.ca [nc] RewriteRule ^(.*)$ http://www.en-domain.ca/en/$1 [R=permanent,nc,L] Code (markup): So traffic going to fr-domain (.ca + .com) would redirect to folder /fr/ and domain-en would redirect to folder /en/ Thanks
Hi, I am trying to turn this --> newyork.domain.com into this --> testsite.domain.com/index.php?region=245 I have wildcard subdomains setup on my server so you can type in anything like: anywhere.domain.com and get the content of testsite.domain.com so that is working correctly. I have a text file (map-list.txt)with the contents in this format: newyork 245 losangeles 246 boston 247 ... Here is the last few lines of httpd.conf RewriteEngine on RewriteMap city txt:/home/username/public_html/testsite/map-list.txt RewriteCond %{HTTP_HOST} ^([^.]+).domain.com$ RewriteRule ^(.*)$ index.php?region=${city:%1¦http://domain.com/nocity.htm} But it does not change the region when I go to newyork.domain.com Any direction on this would be appreciated.
I have tried this : Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteRule ^tag/([A-Za-z0-9]+)/([^/]*)/?$ /free_cinema/search.php?cx=012382053942475672257:9pn8jrqczsw&cof=FORID%3A11&q=$1 [R=301,L] RewriteRule ^video/([a-z0-9]+)/([^/]*)/?$ /free_cinema/index_video.php?reqVideoId=$1 [R=301,L] but it doesn't works .. but when i changed into : Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteRule ^tag/([A-Za-z0-9]+)/([^/]*)/?$ /free_cinema/search.php?cx=012382053942475672257:9pn8jrqczsw&cof=FORID%3A11&q=$1 [L] RewriteRule ^video/([a-z0-9]+)/([^/]*)/?$ /free_cinema/index_video.php?reqVideoId=$1 [L] it's works, but the css styles are gone, the page looks so ugly anyone know what does wrong? thx so much -tibz-
My guess is that you are linking the stylesheets with relative URLs. If you do a redirect, the URL you are requesting changes to /free_cinema/ but without the redirect the URL stays as /tag/sometag/otherstuff/. If you have stylesheets in the /free_cinema/styles.css directory then your users will be looking for them in /tag/sometag/otherstuff/styles.css. You should be able to see your users looking for these files in the 404 errors in your error logs. If you change your stylesheet links to have an absolute path ("/free_cinema/styles.css" instead of "styles.css") then your stylesheets should work again.
thanks so much for this tip! it took me awhile to wade through this thread but it was well worth it! alot easier than reading the actual docs.
Great post thanks for throwing it up here. It just saved me a lot of work trying to do the same thing a different way.
can any one help me ?!! I am planning for a new SMF Forum Currently i m on Litespeed servers, i just applied SEO4SMF Mod to my Forum to make URLs user friendly But as my server is NON Apache (Its Litespeed) How can i make URL SEO friendly bcoz it stated that "For Apache only" i heard that Litespeed supports the Apaches functions so how i can make it ON , or how can i convert them ? i m new to Site Server admin so have no idea about all such stuff Please give me through solution for this problem i have seen the Main topic of this thread its about the Apache is there any way to convert the Litespeed in apache ?