This question already has an answer here:
Friendly Url .htaccess
(1 answer)
Closed 8 years ago.
my url is
http://altikalti.com/down.php?folderpath=53/143&imageid=29&file=17Mar2014-murzuq-band-ghat-festival-libya(altikalti.com).jpg&new
output url:
http://altikalti.com/53/143/29/17Mar2014-murzuq-band-ghat-festival-libya(altikalti.com).jpg
How can i do.. if any changes in panel setting then you can also suggest me
thank u for reading...
Have a good day
Create .htaccess file into root folder (e.g. http://altikalti.com/ location)
RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*)/(.*) http://altikalti.com/down.php folderpath=$1/$2&imageid=$3&file=$4&new [L]
If you're not in production environment, you can check if mod-rewrite is enabled by
RewriteEngine On
RewriteRule ^(.*) http://www.google.com/ [L, R=301]
If it work every request should be redirect to google.com, which mean the first script should work and do the job for you.
This question has been asked several times already.
By searching with the keywords friendly url htaccess you can find this discussion that give an answer on the subject :
Friendly Url .htaccess
Or this one, especially for images :
Friendly URL for images
You can still follow this blog post for more complete examples :
http://surefirewebservices.com/tutorials/friendly-url-tutorial-pt1
Related
I know this question has been ask often. I leverage the links here but still cannot get it to work
source: link
what am trying to achieve:
I have Original URL:
Eg: http://localhost/followersid.php?id=101data
which am trying to rewrite as follows
Eg: http://localhost/followers
.htaccess Code
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/\followers$ followersid.php?id=$1
My ISSUE: When I type http://localhost/followers in the url, it says The requested URL was not found on this server whereas followersid.php is in the same directory with .htaccess files
It was a regex issue. this is what solve the problem
RewriteRule ^([a-zA-Z0-9_-]+) followersid.php?id=$1
This question already has answers here:
replacing .php ext with .html through .htaccess
(4 answers)
Closed 8 years ago.
I am developing a website in my localhost using xampp. I want to make SEO friendly url like this.
Currently I access the page like this,
http://example.com/myproject/page.php?id=10
I want to change this as bellow,
http://example.com/myproject/page.html?id=10
I tried this using .htaccess, but sometimes I found it redirecting to .php, but I don't like so. I need permanent fix. So when user type .html it will access .php files, but no extension will change on their browser.
try this
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php
when you will access page1.html the system will look for: page1.php
This question already has answers here:
How can I remove file extension from a website address?
(11 answers)
Closed 9 years ago.
I have a build a few sites for my website. They all end with .php.
The problem is if you want to view the page you have to type in website.com/page.php instead of website.com/page. How do I make this happen for all of my main pages?
Is there a quick way of doing this, or do you have to set up a forwarding for all of the /pages to the /page.php?
In most cases this is achieved using MVC framework and Routing. It works in a way that you don't access single .php file for single web page you show to user. Every request goes through one file and you have a router where you define your routes and then define what action controller would that route invoke, and from there you choose what view file will you show to the user. Its hard to explain in few sentances. Anyway using MVC you get nice URL-s like www.example.com/controller/action/param
Now if you just want to remove .php extension from your files you can put this in your .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
But other then hiding .php, it wont do any good.
The best thing you can do is to read about MVC frameworks, Routing and Front Controller pattern, and take it from there, its not all about nice URL-s, there's much more to gain! And if you just want to hide .php extension then use above code.
Hope this helps!
You save your first file as index.php (index.php is the default page) and include or redirect all the other files internally. So there would be no reason to type a file name.
You can also use apache on .htaccess to rewrite your files, but you have to be careful with this.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
mod_rewrite, php and the .htaccess file
Would like this to happen in the .htaccess file.
to rewrite
index.php?pagetype=name
to
/pagetype/name/
do this for all pagetypes so
?user=name
?post=number
?life=sucks ... etc
but would like to exclude
/css/
/images/
/js/
/php/
/template/
so the variable links still work.
I am guessing this should work but I want it in it's most simplest form so I don't have to change the .htaccess file everytime I add a pagetype.
I did a search for this but didn't find anything helpful.
The site will only have one physically accessed file: index.php then the rest are processed via $_GET commands
Just for the example you specified, the simplest approach would be:
RewriteCond %{REQUEST_URI} !^/(css|images|js|php|template)/
RewriteRule ^(\w+)/(\w+)/?$ index.php?$1=$2 [QSA,L]
(The RewriteCond could be written as negative lookeahead in the Rule instead of course.)
See also the mod-rewrite tag wiki for further howtos.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to create friendly URL in php?
I have read a lot of content on Google about turning
profile.php?id=24 into something more user friendly.
How would I go about redirecting a link like
www.site.com/profile/username
to
profile.php?id=userid (find from username)
Thanks
This can be achieved with the Apache mod_rewrite RewriteEngine. An example .htaccess:
RewriteEngine On
RewriteRule ^/profile/username/([\d]+)$ profile.php?id=$1
You can do that with apache rewrite rules.
Apache will internally rewrite a URL like /profile/username to profile.php?username=username.
Example: (place this in a .htaccess in the same directory than profile.php)
RewriteEngine On
RewriteRule ^/profile/(.*)$ profile.php?username=$1
If you profile.php script doesn't accept a username parameter, you could also include the user id in the user friendly url:
RewriteEngine On
RewriteRule ^/profile/(.*)-(\d+)$ profile.php?id=$2
This will rewrite urls like /profile/username-id to profile.php?id=id
See apahe mod_rewrite documentation.
This is done by creating a RewriteRule in a .htaccess file, of by defining rules in httpd.conf.
This works on Apache. I'm, not sure how to do this on other servers.
When your users sign up, use a PHP or CGI script to make a file called "Username.txt" and store it in a folder called Profiles (as you have it). And inside the text file, make it generate the number (counting up or hashed?) Or use a rewrite service in Google or Apache.