I've a URL which get file name through get method and display it on the page.
tvchaska.info/i/
this is the page and when u click any image it will go to say
http://tvchaska.info/i/output.php?i=http://brothertattoo.co.uk/wp-content/uploads/2011/09/Sexy-Girl-Tattoo.jpg
I want my this URL to be rewritten as tvchaska.info/i/Sexy-Girl-Tattoo.html
I tried following rule but it is not working
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /output.php?i=$1 [L]
Can any one plz help me to attain this plz?
I've seen you page, I'll give you the answer only if I can meet 3 girls of your page IRL! Just kidding.
Here's the solution:
-1: all your link don't have to be like:
/i/output.php?i=http://1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg
but something like:
/i/1.bp.blogspot.com/_R2Wo1mDtuko/TGzOFQEhpoI/AAAAAAAACAA/Na-WQ1xe7dY/s1600/sexy.jpg
-2: once you've modified your site, apply those rules:
RewriteEngine On
RewriteRule ^/i/(.*)+ /i/output.php?i=http://$1
This will do the job.
Olivier
Related
I have a website that looks like this (the Ferrari is not a physical folder is an alias virtual):
www.example.com/en/ferrari
and I would like to convert this site into a sub-domain, like so:
ferrari.example.com
or something like:
ferrari.example.com/en/
The idea is to have all sub-pages from the Ferrari section working inside the sub-domain.
I don't know if this is even possible, all my .htaccess test didn't worked out.
I am searching for a re-write rule but I don't seem to find it.
EDIT:
Let me rephrase the question, I don't want to REDIRECT from example.com/ferrari to ferrari.example.com
What I want is to show the example.com/ferrari site when someone opens ferrari.example.com. That is the difficult part. If someone opens ford.example.com, I want to show all the pages that are inside example.com/ford.
You can use that in your root .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ferrari\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/en/ferraricars [NC]
RewriteRule ^(?:en/)?(.*) en/ferraricars/$1 [NC,L]
Work with ferrari.example.com/en/other and ferrari.example.com/other -> example.com/en/ferraricars/other
I had faved this link a year ago and it worked for me.
PS: I don't remember, and I'm not sure, but I think that I have added some other flags in the htaccess. Let me know if it not working on comments.
With directadmin it would be possible with creating a subdomain + hatcc redirect
I change my URL name using mod write. But my URL doesn't show the changes on browser.
This is how it looks from before and after
www.mydomain.com/toy/image.php
to this
www.mydomain.com/toy/xbox
How can I make this: www.mydomain.com/toy/xbox appear on the browser
Another words on my website it should appear www.mydomain.com/toy/xbox instead of this
www.mydomain.com/toy/image.php
This is my code:
RewriteEngine On
RewriteRule ^toy/xbox$ /toy/image.php* [L,R]
Can someone to explain to me how it works. Did I missed a step? Do I need to used PHP?
If I did make a mistake, correct me so I can learn from my mistakes. I try to google this but I couldn't find what I need to do
Any links or explanations would be appreciated. Thanks.
For it to "show the URL," you need it to do a 301/302 redirect, with a location header. All you have to do is end your RewriteRule line with [L,R=301]
You must perform a redirect using the R flag instead of just a rewrite.
RewriteRule ... ... [R]
Here's the scenario, I have a website that used to be a static HTML site and WordPress blog using a subdomain (http://blog.domain.com).
I recently combined everything into a single WordPress installation. To maintain old links I had to rewrite requests like "http://blog.domain.com/index.php/2010/10/16/post-name" to "http://domain.com/index.php/2010/10/16/post-name". My problem is that when trying to visit just "http://blog.domain.com", I get redirected to "http://domain.com" when I want it to go to "http://domain.com/index.php/blog".
So, if a user requests "http://blog.domain.com" (by itself, with or without slash), I want it to go to "http://domain.com/index.php/blog". If they request an old URL of "http://blog.domain.com/some-link-to-a-post", I want it to redirect to "http://domain.com/some-link-to-a-post". In other words, if it's a URL to an actual post, I just want to strip the "blog" subdomain. If it's the old link to the main blog page, I want to remove the "blog" subdomain and append "/index.php/blog"
http://blog.domain.com/ -> http://domain.com/index.php/blog
http://blog.domain.com/index.php/2010/10/16/post-title -> http://domain.com/index.php/2010/10/16/post-title
Hopefully that's clear. I'm not an htaccess expert, so hopefully someone can help me out here. Thanks in advance!
Using the [L] command at the end of a rewrite will tell htaccess that this is the last rule it should match. If you put a rule to match your first condition at the top and the other rewrite rule you said you had already created after it, you should get your expected result.
Try this:
RewriteRule ^blog.domain.com(/?)$ domain.com/index.php/blog [L]
# Your other rewrite here #
I couldn't get that solution to work. However, I used the following:
RewriteCond %{HTTP_HOST} ^blog\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/index.php/blog/$1 [R=301,L]
That ends up in a URL like http://domain.com/index.php/blog/index.php/2010/06/04/post-title, but Wordpress is smart enough to fix it.
i tried to create this url rule buts not working: i dont know why :(
orginal url
www.example.com/viewprofile.php?username=jhon
the desired friendly url is
www.example.com/user/jhon
this is my.htaccess code:
RewriteEngine On
RewriteRule ^username/([^/]*)$ /viewprofile.php?username=$1 [L]
thanks for helping!! :))
I found this tutorial where the author explain step by step how to do exactly what you are trying to do. See if it helps: http://www.emanueleferonato.com/2008/06/15/how-to-generate-friendly-urls-with-htaccess-part-2/
I've added a .htaccess file to my root folder for the purposes of rewriting dynamic URLs into static ones. This seems to have been done successfully but I am having problems with page numbers.
For example, if you were to visit a static page /widgets, the first page of the products is fine....but subsequent pages show up as /products.php?cat=27&pg=2 etc. What I want is for subsequent pages to be in the form of /widgets-pg2 or /widgets?pg=2.
Below is my rewrite rule that I used for the initial category page:-
RewriteRule ^widgets$ products.php?cat=27
If any of you experts can help with this, it would be much appreciated.
Are you expecting the cat to change as well? You'd need to account for that in your URL as well:
e.g. www.site.com/widgets/27/2 could be rewritten as:
RewriteRule ^widgets/([0-9]+)/([0-9]+)$ products.php?cat=$1&pg=$2
If widgets will always be cat 27 then you can change it to:
RewriteRule ^widgets$ products.php?cat=27 [QSA]
which is query string append
Try
RewriteRule ^widgets-pg(.+)$ products.php?cat=27&pg=$1
After that, go here :)
To allow a query string after your rewritten URL use the [QSA] flag:
RewriteRule ^widgets$ products.php?cat=27 [QSA]
A link would than be:
http://example.org/widgets?pg=167&perpage=100&tralala=Hi!
I tried the following but it resulted in a '404 Not Found' error when I go to /widgets:-
RewriteRule ^widgets-pg(.+)$ products.php?cat=27&pg=$1
And I tried the following:-
RewriteRule ^widgets$ products.php?cat=27 [QSA]
This worked correctly but to go to page two of the widgets page, I need to type in the browser:-
/widgets?pg=2
But the actual 'page 2' link still leads to:-
products.php?cat=27&pg=2
So apart from a rewrite rule....maybe I need a separate redirection rule? Or maybe need to change the page number links. But since these are dynamically generated, I'm not sure how to do this.
The following is the PHP code for the page:- http://freetexthost.com/3ubiydspzm