hi Nintendo, yes, the wildcard DNS is already enabled for the specific test domain and i can even get a anything.example.com = example.com/search?q=anything my current code is almost working.. but might need some minimal adjustments. thank you still for looking at my concern. cheers!
???????? Please clarify what rewrites you want to make exactly.. In the meantime you can this code to redirect http://example.com/search.php?q=yyyy:askapache: ==> http://askapache.example.com/ RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^([a-z]+\.)?(.+)\.com [NC] RewriteCond %{REQUEST_URI} ^/search\.php [NC] RewriteCond %{QUERY_STRING} ^q=([a-z]+):([a-z]+): [NC] RewriteRule .* http://%4.%2.com/? [L,R=301] Code (markup): Or to redirect http://example.com/search.php?q=apachecategory:askapache: ==> http://askapache-apachecategory.example.com/ RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^([a-z]+\.)?(.+)\.com [NC] RewriteCond %{REQUEST_URI} ^/search\.php [NC] RewriteCond %{QUERY_STRING} ^q=([a-z]+):([a-z]+): [NC] RewriteRule .* http://%4-%3.%2.com/? [L,R=301] Code (markup):
Hi apachehtaccess, it would be best if i can make the rewrite as xxxx.example.com but considering the variable yyyy on the search string example.com/search.php?q=yyyy:xxxx: i guess its not possible as it would collide with the other variables of yyyy so the xxxx-yyyy.example.com output is acceptable. -------------- I tried your code below and it gives me a output of xxxx-yyyy.example.com for example.com/search.php?q=yyyy:xxxx: but the variable yyyy is not recognized properly. if for example. example.com/search.php?q=zzzz:xxxx: it still gives me a search result of example.com/search.php?q=yyyy:xxxx: i hope i explained it well thanks apachehtaccess for the help!
Ooops! This code works. RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/search\.php [NC] RewriteCond %{QUERY_STRING} ^q=([a-z]+):([a-z]+): [NC] RewriteRule .* http://%2-%1.example.com/? [L,R=301] Code (markup):
Except I don't think he wants a redirect, he want's xxxx-yyyy.example.com to look exactly like example.com/search.php?q=yyyy:xxxx: as if the sub domain is the real URL.
yes nintendo you are correct. but on consultation with other SEO people, some adviced that this is an SEO overkill and might be redflagged. I am abandoning the idea for now. Thanks again to Nintendo and apachehtaccess!!!!! any help is very much appreciated. regards,
I'm not sure what you mean.. So he doesn't want example.com/search.php?q=yyyy:xxxx: to be redirected?
digital-point.example.com being the exact same thing as www.example.com/search.php?q=point:digital: as if the sub-domain was the real URL.
Oh ok... man that would have been a lot simpler if I would have known that! lol So now you don't even want the answer?
Internally (transparent to the user) redirects http://digital-point.example.com => /search.php?q=point:digital: Code (markup): RewriteEngine On RewriteBase / RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ - [L] RewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC] RewriteCond %{HTTP_HOST} ^([a-z]+)?-?([a-z]+)?\.example\.com$ [NC] RewriteRule .* /search.php?q=%2:%1: [L] Code (markup):
Hello, While I have worked a fair amount with htaccess, I have not really worked a lot with mod_rewrite. What I am looking to do is pretty simple. Due to a site conversion to WordPress, I am looking to change the URL from the old layout, which uses a PHP script for an Ask The Experts section, to the Wordpress page. Basically, this is what I looking for: From: http://www.beautynewsnyc.com/asktheexperts/index.php?act=Question&id=1 To: http://www.beautynewsnyc.com/ask-the-experts/index.php?act=Question&id=1 and From: http://www.beautynewsnyc.com/asktheexperts/index.php?act=Answer&cid=5&id=405 To: http://www.beautynewsnyc.com/ask-the-experts/index.php?act=Answer&cid=5&id=405 Here is the code I am using for the redirects: Options +FollowSymlinks RewriteEngine on RewriteRule ^asktheexperts/index.php?act=Question&id=([0-9][0-9])$ ask-the-experts/index.php?act=Question&id=$1[nc] RewriteRule ^asktheexperts/index.php/act=Answer&cid=([0-9][0-9][0-9])&id=([0-9][0-9][0-9])$ ask-the-experts/index.php?act=Answer&cid=$1&id=$2[nc] All that would change would be the directory, from asktheexperts to ask-the-experts. Any help would be greatly appreciated.
Hi guys, apache 2.2 winxp pro php5 I'm having trouble with getting mod_rewrite to work on my machine with the above configuration. I'm new to mod_rewrite. If I run phpinfo(); it tells me I have succesfully loaded mod_rewrite. however I cannot get any mod_rewrite rule to work. here are the parts of httpd.conf I have changed: LoadModule rewrite_module modules/mod_rewrite.so DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" <Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all Satisfy all </Directory> And I am trying to use a .htaccess file with the following in it: Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^wacko\.html$ index.html [L] (so when I browse http://localhost/wacko.html it should redirect me to http://localhost/index.html) This is not working, nor any mod_rewrite I try. I'm sure it must be something with the httpd.conf file but I have tried for days with no success. My main questions are: 1. Is my mod_rewrite module active? (does it need to be in apache2+?) 2. Is my httpd.conf configuration ok 3. WHERE AM I GOING WRONG? any help would be greatly appreciated. Thank you! Roark
mod_rewrite is worthless if you still have the index.php?act=Question&id=1 kinds of URLs. You want it as static URLs. Test it out on an actual domain.com/IP URL.
Nintendo, thanks for the advice, at the moment I am hosted on a iis server, at the moment I am trying out apache as I would like to upgrade to it. so i wont be able to test it out on a real domain for a while. Is it a common problem getting mod_rewrite working on localhost? If so, is there a solution for it? It would be handy to get it working on my machine locally for testing purposes. Thanks for the help Roark
Hey Guys I just could not find anything or anyone that had the same problem and posted about it. But I found a solution... When you, nintendo, said that you've never tried it on localhost before, made me think that that may be the issue, http://localhost/. so I changed the url in my address bar to http://127.0.0.1/ and my rewrite rule worked. (Using the ip address of my machine locally) Maybe you guys know why that made it work all of a sudden, I don't really know enough to try guess. but it worked... (I hope it helps some other people who might sit for 4 evenings looking for the solution) P.S. Thanks for the resources (apachehtaccess) I bookmarked that one. Cheers Roark
You could even setup your actual domain on your local XP machine running apache. All the mod rewrite stuffs would work fine in this environment. You would need to configure your domain name in the virtual host section of apache configuration(httpd.conf) and also need to edit the hosts file (windows/system32/drivers/etc/hosts) to add the following lines. 127.0.0.1 www.example.com 127.0.0.1 example.com So you can actually access the local files with http://www.example.com/ instead of localhost/127.0.0.1 When you are out of testing mode, remove the lines only from hosts file. You will be served directly from the actual remote server. I hope you can understand this.
Brilliant... Thanks vishwaa, thats a great idea. I know that I'd need to change my hosts file, can you elaborate as to what changes I'd make in my httpd.conf file? I think i might try that. Thanks Roark