I need some help figuring out how to write this .htaccess.
My file is in mywebsite/part5/thanksfordownload.html. How to use .htaccess to have url mywebsite/thankyoufordownload.html?
I tried using this for the .htaccess but no dice. I tried uploading it both in the root and in the folder itself.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /part5/$1 [L]
Not sure what went wrong in this part,
thanks for your views & comments in advance!
Ok so basically if you only want that rule - you'd want to do something like this -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^thankyoufordownload.html$ /part5/thankyoufordownload.html [L]
Simply:
RewriteRule ^thankyoufordownload.html$ part5/thanksfordownload.html
This will only work for the example asked about.
Related
I am passing a name which will be used as the subfolder but the filename remains the same eg foldername/gallery.php?q=new_folder should be new_folder/gallery.php using htaccess.
Attaching the htaccess of what I a trying to do
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(gallery.php)$ $2.php?q=$1 [L]
gallery.php is the filename and $1 is basically the new_folder. Been struggling with this for quite a bit.
You are fairly close. You just need to use foldername/ in target URI of your rule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(gallery\.php)$ foldername/$2.php?q=$1 [L,QSA,NC]
I have just added bellow mentioned code in .htaccess. Hope this will help you.
RewriteEngine On
RewriteRule ^foldername/(.*) http://example.com/newfolder/gallery.php?options=$1 [R=301,L]
Right now my URL looks like:
https://www.example.com/blogitem.php?id=29
What I want is the user will see the URL in their browser like:
https://www.example.com/blogitem/the-title-of-the-current-blog
This thing is already implemented in Wordpress and other CMS but I am using pure PHP and don't have any idea about how can I implement this feature. Can anyone please help me to implement this?
write this on code .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ blogitem.php?id=$1 [L,QSA]
you need to get title form database instead of id
so it will be like this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ blogitem.php?title=$1 [L,QSA]
I have the following code on my htaccess:
RewriteEngine On
RewriteRule ^course-details/([a-zA-Z0-9]+)/$ course-details.php?id=$1
I think this gave me a URL like this: /cp/course-details/5 where 5 is the id of the course.
But when I go to this address I get 404 not found. Also, our current url is
/cp/course-details.php?course-details.php?name=bla-bla-bla&category_id=1
and we need a friendly url like this
cp/category-name/course-name/
Thanks in advance for you help.
You can try this in your htaccess file if the php file is in the cp dir. Since it appears your are developing in a subfolder(peppers) of your dev box you can try this.
RewriteEngine On
RewriteBase /peppers/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cp/course-details/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
If this is for production then you can use this in the .htaccess file in the root.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cp/course-details/([^/]+)/?$ /cp/course-details.php?name=$1 [NC,L]
RewriteRule ^course-details/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/.*$ course-details.php?id=$1&category_id=$2
With that, you can use URL like course-details/1/5/category-name/course-name
Because URL allow: course-details/category_id/id/what-ever-you-want
I got a webpage that has the following URL:
localhost/Minecraft-User-Info/player/?user=matthijs110
Now I want it to localhost/Minecraft-User-Info/player/matthijs110
So without ?user=matthijs110
I tried different ways, but it doesn't seem to work. Mod_Rewrite is enabled.
What can I do to get this to work?
Give this a try.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Minecraft-User-Info/player/(.+)$ /Minecraft-User-Info/player/?user=$1 [L]
Edit:
Use this since it's in a sub directory.
RewriteEngine On
RewriteBase /Minecraft-User-Info/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^player/(.+)$ player/?user=$1 [L]
Updated to show my original answer and included the edit per users comment about where htaccess is located.
Try this instead. Minecraft-User-Info/player/username Redirects to Minecraft-User-Info/player/index.php?user=username
Tested on http://htaccess.madewithlove.be/ instead of setting up my own server for it.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Minecraft-User-Info/player/(.+)$ /Minecraft-User-Info/player/index.php?user=$1 [L]
Try this
RewriteRule ^Minecraft-User-Info/player/([a-zA-Z0-9_-]+)\$ index.php?playerId=$1
can anybody please tell me the rewrite rule so I can make a URL like this:
http://www.mysite.com/index.php?page=directory1/page
what I'm trying to do is remove the "index.php?page=" so i get a
"http://www.mysite.com/directory1/page"
This is how Drupal does it; it's very similar to toneplex's example, but it doesn't mess around with extension checking and it adds an extra check on favicon.ico, which many browsers automatically request; this saves an extra hit on your PHP code if you're missing favicon.ico.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
I'm assuming you are trying to bootstrap everything via the index.php file. So try this out. Any file or directory that doesn't exist will be force through the index.php file.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php