we are moving website platforms. The old site has some url rewriting built into it, so the urls look like "/product-name-here-1.aspx". I need to get the id out of this url using Isapi-Rewrite syntax.
I've got a map file that takes the id and redirect to the page on the new platform.
thanks in advance.
I guess it should be something like this:
RewriteBase /
RewriteRule ^.+-(\d+)\.aspx$ ...
Not sure what the right part of the rule should be as you haven't specified that.
Related
I am trying to rewrite URLS in my website but unable to do so.
I am using Lightspeed in Cyberpanel. The .htaccess code I used is:
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
What my url looks right now: mysite.tld/index.php?a=2322
What I want to look it like: mysite.tld/2322
Thanks in advance!
I have this application that I want to support multi languages.
I thought the easiest way would be to use sub domains aka
http://fr.domain.com/content
Now I created the sub domain on my server, pointing to the main root and indeed, the above URL is accessible.
The problem now are all my links, which are absolute.
Is there a way with mod_rewrite to catch the language from the URL and than rewrite the links to the same sub domain URL?
So if we are on http://fr.domain.com/content and click the link http://domain.com/link I want the page to load as http://fr.domain.com/link
Is that possible?
Cheers!
You would probably have to check HTTP_REFERER if you want to do this through apache. It might be good to start updating the site so that the links are dynamic in the future...
Something like (I can't really test this currently):
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_HOST} !^[a-z]{2}\.host\.com$ [NC]
RewriteCond %{HTTP_REFERER} ^http://([a-z]{2})\.host.com/.*$ [NC]
RewriteRule (.*) http://%1.host.com/$1 [R,L,QSA]
EDIT: removed a NOT in the 3rd condition
You might have to check some other conditions, but test things out to figure out what works. Plus, if you do other redirects you need a way to maintain the original referrer. In some ways even with the links the way they are, it may be easier to do this through a more dynamic means with php (through session) or something.
I was using these:
http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html#HTTP_REFERER
http://www.askapache.com/htaccess/modrewrite-tips-tricks.html
You probably need some kind of on-the-fly HTML rewriting tool like mod_proxy_html. This tool was specically designed for rewriting the links in pages on the other side of a reverse proxy but it should be possible to use it for generic link rewriting. Specifically the docs say:
Normally, mod_proxy_html will refuse to run when not in a proxy or when the contents are not HTML. This can be overridden (at your own risk) by setting the environment variable PROXY_HTML_FORCE (e.g. with the SetEnv directive).
The module is quite configurable and supports conditional rewriting and regexes so with some tweaking it should do what you want.
So you're saying your website has links like <a href="http://domain.com/link"> instead of just <a href="/link">??? Is there some reason your links are coded like that?
Would you be happy with whipping out a text editor and search/replace'ing those hrefs instead of doing something a-typical or excessively complex with URL rewriting?
i'm trying to use iirf for what looks like asimple rewrite but it's not working.
what i need:
rewrite http://www.mydomain.com/ru to : http://www.mydomain.com?page=russian
the objective being that a get param would be sent but the user would see the first url on their browser's url bar.
i'm using the following code:
RewriteEngine ON
StatusUrl /iirfStatus
RewriteRule http://www.mydomain.com/ru http://www.mydomain.com?page=russian
does this go (the iirf file) on the site's root or in a 'ru' subfolder (tried both)?
what am i doing wrong or missing?
thanx and have a nice day :-)
The following should work:
RewriteRule ^/ru$ /?page=russian [I,L]
You should put this in the iirf.ini file in the web sites root folder.
Check http://www.mydomain.com/iirfStatus to see whether iirf was able to read your configuration file.
Also, you may use RewriteLogLevel with a value of 2 or 3 and RewriteLog to see whether the incoming url was rewritten, and how (or why not).
I have a site where my pages are generated dynamically. I want to change the url from:
http://www.mydomain.com/library.php?id=13
to something like:
http://www.mydomain.com/13.html
I am using this Rewrite Rule:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /library.php?id=$1 [L]
Unfortunately it doesn't work. When I click on the link the page goes to this url:
www.mydomain.com/library.php?id=13
But the strange part is when I browse to www.mydomain.com/13.html the link is working.
What am I missing?
You need to change the links that are generated in the library.php files to your new defined format :)
I'm using Joomla 1.5.14 and I configured SEO as in the following image
Now I need to map a few old URL to the new site
let's say that I need to map htp://mysite/old.html to the new Joomla page
http://mysite/index.php?option=com_content&view=article&id=32&Itemid=70
I added in my .htaccess file the following
RewriteRule ^old\.html$ index.php?option=com_content&view=article&id=32&Itemid=70 #works!!
this works fine, but if I use the SEF URL in .htaccess (let's say the above page can be reached with htp://mysite/contacts.html), I obtain a 404 error
RewriteRule ^old\.html$ contacts.html #this does not work
Now the question:
Is it possible use SEF URLs in RewriteRule? where am I wrong?
thank you in advance
stefano
I think the problem is because Apache rewrites old.html to a page that doesn't actually exist, but rewritten in a different rule.
If you truly want to "rewrite" - in other words, have the page stay as old.html in the browser - then you don't need to do anything.
However to avoid duplicate content it's probably better to do a 301 redirect:
Redirect 301 old.html http://yoursite.com/contact.html
(You may need a forward slash at the front of old.html)