iirf rewrite url - 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).

Related

Rewrite numbers to default page

I am trying to rewrite a condition that can take any page that has numbers.html, lets say the like the following:
12345.html
33443.html
234545656.html
9797423.html
and just redirect it to index.php
RewriteRule ^([0-9]+)$ index.php [L]
I tried the following but it doesn't work, any help is very much appreciated.
Two immediate issues with your code:
you have to switch on the rewriting engine prior to using it and
if you want to match file names ending with .html, then you have to code that.
Have a try with this:
RewriteEngine on
RewriteRule ^([0-9]+)\.html$ index.php [L]
Then a few more hints:
the code you tried will only work in .htaccess style files. But the usage of such files has to be enabled first in your http server configuration.
a .htaccess style file has to be placed at the correct location, in this example within the folder actually holding the index.php file.
the rewriting module has to be installed and enabled, without those commands will not be available.
And a general remark:
Those .htaccess style files are notoriously error prone, hard to debug and they really slow down the http server, often for nothing. You should always prefer to place such commands inside the real host configuration of your http server. .htaccess style files are only offered as a last option for situations where you have no access to that configuration, for example when using a really cheap shared hosting provider.

URL Rewriting all subsites to main site

I'm new with URL Rewriting and dont know how to do this:
All sites after /ex1 should be redirect to index.php
My current script:
RewriteEngine On
RewriteRule ^(ex1|ex2)/?$ index.php [NC,L]
But this will only rewrite example.com/ex1/and not example.com/ex1/abcd
Thanks in advance ;)
Close to perfect, try this instead:
RewriteEngine On
RewriteRule ^(ex1|ex2)/? index.php [NC,L]
Note: the trailing $ in the regular expression has been removed. That one was the cause why only the exact urls example.com/ex1 and example.com/ex1/ were matched, but no longer ones. The trailing $ anchors the search to the line end, so the end of the url here. So if there is anything between the last matched characters (the ex1 or ex1/ in this case), then the expression will not match.
Another more general note: this pattern is only usable withing .htaccess style files, but not in the normal hosts configuration. There are situations when such files come in handy, for example if you do not have administrative control over the http server. But in general you should always prefer to place such things inside the http servers hosts configuration instead of using .htaccess style files. Reason is that such files are notoriously error prone, hard to debug and finally really slow the server down.

how to redirect a link in my website to an external link?

I have provided a link from my web site in my andoird app which is:
www.mysite.com/support
And i want this link to be redirected to:
www.anothersite.com
i have already tried com_redirect and entered support as source and http://ww.anothersite.com but i dont get any redirects and i get 404 error.
I am running Joomla 3.x and i want to know how i can do this with URL rewrites and no external components.
It seems not possible to do it within the Joomla backend (i tried many combination of menu items and the redirect module).
For sure you can write your redirect directly in your .htaccess (if you are using it) like this:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com/ [R=301,NC,L] # Permanent Move
or
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com [R,NC,L] # Temporary Move
More info about URL rewriting and .htaccess are here: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

mod_rewrite proxy URL missing images/css

I have the following mod_rewrite using Proxy flag to redirect from one URL folder to another site subdomain as follow:
The .htaccess file placed inside http://www.domain.com/test/ folder:
RewriteEngine on
RewriteRule ^($|/.*) http://subsite.site.com/$1 [L,P]
The problem, images, CSS and links are not showing up properly. Links appear to be pointing back to: http:// www. domin .com/linkname.html
I've tried doing RewriteBase /test/ and / with no luck, and couldn't figure out any other way to do it.
What am I missing in above code to make it work with relative paths at destination URL?
Oh, you want to change internal content?
Mod_rewrite only changes headers, not content and you would definitely need something else like mod_proxy_html. However, rewriting content just to change urls can normally be completely avoided (assuming you have control of your content) by making all paths legitimately relative. In such cases all paths in content should be like: linkname.html or some_path_from_here/linkname.html instead of /linkname.html or some_path_from_here/linkname.html

Isapi ReWrite: How can I match a part of a url?

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.

Resources