I am redirecting to index page with 2 parameters which is inside child folder.
Root folder - child folder - file -> url should be like domain_name.com/child_folder/Arg1/Arg2.
I'm able to do it with htaccess. but in nginx it is not working.
this is the code in htaccess.
RewriteRule ^apply-to-speak/([a-z0-9-]+)/([a-z0-9-]+)/?$ apply-to-speak/index.php?tid=$1&pid=$2 [L,NC,QSA]
htaccess to nginx converter gave this code -
location /apply {
rewrite ^/apply-to-speak/([a-z0-9-]+)/([a-z0-9-]+)/?$ /apply-to-speak/index.php?tid=$1&pid=$2 break;
}
this is redirecting to 404 page.
Related
How redirect everything inside rootfolder to 404, except files in root/public folder? Directory listing must be disabled everywhere and .htaccessredirected to 404 as well. It's possible to make that with one .htaccess file?
Currently i have Redirect 404 / in root, but when trying to access .htaccess, it's forbidden. Thanks
To redirect everything inside rootfolder to 404, except files in root/public folder ,you can use the following Rule in your /root/.htaccess .
RewriteEngine on
RewriteRule !public - [R=404,L]
and to disable directory listing for all folder/subfolders, add this line to your /root/.htaccess
Options -Indexes
I want to rewrite (not redirect) all url's of my site to a sub-directory of my site. For example:
http://example.com/example
would load the following:
http://example.com/public/example
Though, requesting http://example.com/public should not load the contents from public/public but from /.
Answers I've found on SO either do the above with redirect (which I don't want) or doesn't account for the special case above.
EDIT: further clarification:
I want every request on my site to go load under the public folder, but without being visible to the visitor. So requesting http://example.com/index.php will load the file from http://example.com/public/index.php. The url in the browser remains unchanged for the user.
Try the following rule :
RewriteEngine on
RewriteRule ^((?!public).+)$ /public/$1 [NC,L]
This will rewrite all requests from root to /public dir.
#Starkeen solved this for an Apache configuration at Redirecting the content of a directory, but not the directory itself as well as some of its subdirectories and files, but we'll soon be moving to Nginx.
His very elegant solution for Apache:
RedirectMatch ^/category/((?!index|images|menu)[^/]+)/?$ /$1
Here, everything in the /category/ directory -- except for /category/index.php, the content of /category/images/ and the content of /category/menu/ -- is redirected to the root folder.
We tried the translation from htaccess to Nginx offered at http://winginx.com/en/htaccess,
location ~ ^/category/((?!index|images|menu)[^/]+)/?$ {
rewrite ^(.*)$ /$1 redirect;
}
but that didn't work.
For some reason, when we finally give up searching for a solution and end up asking for help, we often find one soon after. Here it is -- it works perfectly:
rewrite ^/category/((?!index|images|menu)[^/]+)/(.*)$ /$1 permanent;
A magento website transferred to Nginx and my 301 redirects are not working here.
Previous URL:
www.domain.com/store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html
New URL:
www.domain.com//two-year-supply-of-glide-r-chow-glide-a-mins.html
Initially my .htaccess was
Redirect 301 /store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html /two-year-supply-of-glide-r-chow-glide-a-mins.html
and now I have convert it to Nginx server format i.e.
location /store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html {
rewrite ^(.*)$ /two-year-supply-of-glide-r-chow-glide-a-mins.html redirect;
}
Which is not working.
You conversion looks fine to me. sometime nginx server ignore .htacess file try with a new file named as nginx.conf and put your all htacess conversion in this.
Edit
# nginx configuration
location /store { rewrite ^/store/food/(.*)$ /$1 redirect; }
I think this might help you.
I have tried but have not found proper solution for PHP .htaccess
Folder and files information:
.htaccess (on root)
/profile/personal.php
/profile/exam/exam_information.php
Sending URLs from (personal.php) and (exam_information.php)
/profile/2012/A1PPOAQU7
........\-------------/ // Friendly URL
/profile/exam/2012/A1PPOAQU7
.............\-------------/ // Friendly URL
I found, htaccess but it works for single URL only. Please check what is wrong in the code.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ /profile/personal.php?pid=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ /profile/personal.php?pid=$1