convert rules from htaccess to nginx - php

hope somebody can help me, in transforming my apache htaccess rules to nginx config
Removing the .php from the url's, so url: "/contac"t displays the file contact.php
Make this paths use their respective php file, for example:
"/products" shows the file products-all.php
"/products/some-category-name" shows the file products-cat.php
"/products/some-category-name/product-name?id=89" shows the file products-detail.php
I tried searching everywhere, but couldn't fine the correct answer, appreciate any help
Thanks

Check following links:
htaccess to nginx

Related

Remove directory name from url? (example.org/folder1/file to example.org/file)

I'm looking to make a goo.gl/bit.ly etc type domain shortener for my private use using my domain. I've got the script set up to make a file etc, my only issue is that I want to have each new file be created into a new folder (redirects/file), but I want to be able to have mydomain.eu/file redirect straight to the file located in the redirects directory. It seems this would be done using the .htaccess file, but I can't get that working. If anybody could provide any advice, it'd be greatly appreciated.
(Also, if anyone could provide info on how I could automatically clear out the redirects folder say, every week, that'd be great. :D )
I'm running Apache on CentOS, if that's relevant.
Thanks in advance!
Try this in your .htaccess file.
RewriteEngine on
RewriteRule ^/(.*)$ redirects/$1 [R=301,L]

is it possible to remove index.php in url without htaccess?

Is it possible in any way to remove index.php in url without using .htaccess
if yes then how.
and if not then how to make htaccess file in xampp server.
how to apply this in live server.
i tried to make through class but i think it is not possible but i want to be sure so please help me on this ...
what i find is something like
$route['(:any)'] = 'index.php/$1';
in htccess every where so i believe it is not possible because it is something doing nothing with php or any language it is server thing and only chance or way we have is htaccess

only file name index.php is not working on apache2

I'm using apache2 on ubuntu. My localhost is working fine and also php is working.
But only file name index.php is not working. If the file name is test.php or anything othe than index.php, it works.
Dont know it is apache prob or php, can anyone please help?
Thankx,
Kamil
Avoid the htaccess file and edit http.conf. It should be the same listing DirectoryIndex there too. Add index.php and see if you get php to render.
Out of curiosity what do you see when you view index.html? It works! ?
Do you mean it's not recognized? You can try to add it to your .htaccess file in the root of your webserver:
DirectoryIndex index.php

Apache 2.2 URL Rewrite not working

I am trying to do a URL Rewrite, but no matter how I try, it seems like the htaccess file do not functioning at all, and it is only returning the directory listing.
Can anyone tell me what else do I need to look at to make it work?
Regards
PlayKid
Make sure you have AllowOveride All set in your vhost conf file.

Please URL Rewrite in php

Please how can I rewrite
Could anybody please rewrite this url?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
to
http://localhost/display_news_cat/14/2
Thank you
Create an .htaccess file in the site directory and add the following lines
RewriteEngine on
RewriteRule ^display_news_cat/([\d]+)/([\d]+)$ display_news_cat.php?news_cat=$1&p=$2
Afaik, this is normally accomplished with Apache .htaccess file rewrite rules.
Is you case this would look something like:
RewriteEngine on
RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2
If this doesn't work, try checking your access logs to see what's happening.
there are different ways to archive this, and it takes only 1 minute to find this out yourself using google. you could:
use an .htacces file with rewrite-rules to let the apache do the rewriting
map everything on localhost/ to an index.php, read and parse the request-string "by hand" hand show the correct site
Also you can hold it in one script use GET to retrieve the values you wish and re-create the URL with that values. I don't know if it will help you..
Anyway a .httacess file will be much more useful for you.

Categories