rewrite

Remove .html and .php extensions with .htaccess

♀尐吖头ヾ 提交于 2019-12-28 02:07:57
问题 How do I remove the file type from my webpages without creating a new directory and naming the file index.php. I want http://example.com/google.html to http://example.com/google. How would I go about doing this. PS: I tried looking at some other tutorials but there to confusing. I do now that it can be done in .htaccess 回答1: Yes, I know that this question was asked multiple times already and is answered, but I will give a little more comprehensive answer based on my experience. Here is the

Remove .html and .php extensions with .htaccess

独自空忆成欢 提交于 2019-12-28 02:07:29
问题 How do I remove the file type from my webpages without creating a new directory and naming the file index.php. I want http://example.com/google.html to http://example.com/google. How would I go about doing this. PS: I tried looking at some other tutorials but there to confusing. I do now that it can be done in .htaccess 回答1: Yes, I know that this question was asked multiple times already and is answered, but I will give a little more comprehensive answer based on my experience. Here is the

二. Apache配置

喜你入骨 提交于 2019-12-27 16:35:19
2.1默认虚拟主机   2.1.1介绍     是一种在单一主机或主机群上,实现多网域服务的方法,可以运行多个 网站 或服务的技术。虚拟主机之间完全独立,并可由用户自行管理,虚拟并非指不存在,而是指空间是由实体的服务器延伸而来,其 硬件 系统可以是基于服务器群,或者单个服务器。   2.1.2配置     #vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf      //编辑虚拟主机配置文件     <VirtualHost *:80>       ServerAdmin admin@wang.com       DocumentRoot "/data/wwwroot/test0920.com"       ServerName test0920.com       ServerAlias www.testdomain.com       ErrorLog "logs/aming.com-error_log"       CustomLog "logs/aming.com-access_log" common     </VirtualHost>     <VirtualHost *:80>      DocumentRoot "/data/wwwroot/testdomain.com"      ServerName

nginx 配置文件

≯℡__Kan透↙ 提交于 2019-12-27 07:28:50
1 页面登录权限 2 显示nginx状态信息 3 访问权限控制 可以设置白名单和黑名单 allow 192.168.75.139; deny all; 4 rewirte 重写 last break 中止rewrite,不在 继续匹配 redirect 返回 临时 重定向的http状态302 permanent 返回永久重定向的http状态301 rewrite ^/shop/(.*\.html)$ /tuangou/$1 break; rewrite ^/shop/(.*\.php)$ http://www.dianping.com/ redirect; if 语法:if (condition){...}   应用环境:server,location if ($http_user_agent ~ Chrome){ rewrite ^(.*)$ /chrome/$1 break; } 匹配用户浏览器 main配置段 http { } http配置:http core 配置一个静态web服务器 ngx_http_core_module 配置框架: http { upstream { .,.. } server { listen IP:PORT; # 虚拟主机 location /URL { if ...{ ... } root "/path/to/somewhere"; ... }

nginx下支持wordpress 的固定链接写法

六眼飞鱼酱① 提交于 2019-12-26 06:27:29
server{ listen 80; server_name www.ruantaoni.cn; root /home/kuangcs/sites/www.ruantaoni.cn; autoindex on; index index.html index.htm index.php; location ~ \.php$ { root /home/kuangcs/sites/www.ruantaoni.cn; fastcgi_pass unix:/run/php/php7.1-fpm.sock; #fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME /home/kuangcs/sites/www.ruantaoni.cn/$fastcgi_script_name; include fastcgi_params; } #固定连接 location / { if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request

Why matches[2] does not return anything in rewrite rule

杀马特。学长 韩版系。学妹 提交于 2019-12-25 17:06:19
问题 I'm trying to redirect URL www.domain.com/some/my-page--woohoo.html to www.domain.com/index.php?pagename=my-page I have this rule that is attached to init via add_action('init', 'create_rewrite_rule', 1, 0); add_rewrite_rule('^.*\/(.*)--woohoo\.html$', 'index.php?pagename=$matches[1]', 'top'); Calling www.domain.com/some/my-page--woohoo.html returns 404, but when is rule changed to add_rewrite_rule('^.*\/(.*)--woohoo\.html$', 'index.php?pagename=my-page', 'top'); everything works. It seems

How can I change a URL using .htaccess?

天涯浪子 提交于 2019-12-25 16:44:14
问题 I want to show the URL http://www.example.com/about-us.php?p=ceo-greeting as http://www.example.com/about-us/ceo-greeting How can I do so using .htaccess ? 回答1: RewriteEngine On RewriteRule ^about-us/(.*) /about-us.php?p=$1 回答2: Here's the complete documentation on mod_rewrite. http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html 来源: https://stackoverflow.com/questions/4564338/how-can-i-change-a-url-using-htaccess

URL Rewriting Nginx

随声附和 提交于 2019-12-25 06:44:50
问题 I'm trying to accomplish a rewrite in nginx, but it isn't working. What I'm trying to do is this: www.website.com/backstage/somepage.php?language=Dutch should become www.website.com/nl/backstage/somepage.php I have added this line to the nginx config (but it isn't doing anything): rewrite ^/nl/backstage/(.*)\.html$ /./backstage/$1.php?language=Dutch last; I hope someone can help :) Thank you. 回答1: humm, I don't understand your rewrite directive, it doesn't make much sense. check the doc :

Grouping file extensions for re-writing URL's [.htaccess]

痞子三分冷 提交于 2019-12-25 05:32:28
问题 How can I group these two together; is it like ".(html|php)$" - please provide the code. Note, the answer should work for all file extensions: what is your thoughts on removing every file extension; comment on the code used - as it is rare to find. RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP RewriteRule (.*)\.html$ $1 [R=301] RewriteCond %{REQUEST_FILENAME}.html -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.html [L] RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP RewriteRule (

How to write htaccess rewrite for subdirectories recursively?

核能气质少年 提交于 2019-12-25 04:09:31
问题 I have an Apache server, hosting a number of websites for my company. I plan to use htaccess, and rewrite the URLs from the "root" directory to a subfolder. Here is my real folder structure: /www (root) /www/beamstyle (beamstyle.com.hk, CodeIgniter framework) /www/beamcard (beamcard.com.hk, Static files) /www/beamcard/app (beamcard.com.hk/app, CodeIgniter framework) ==================================================================== The beamstyle website works using the following code: