网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

使用Wordpress Rewrite或.htaccess重写URL

GG网络技术分享 2025-03-18 16:12 2


问题描述:

I\'m trying to append to wordpress an additional parameter into my URL.

For example, I have the URL: http://example.com I want to change that to URL: http://example.com/this-example/

I\'m thinking I can do this is in htaccess along the lines of a rewrite condition, but i\'m unsure how to go about this. This is what I was thinking here.

Htaccess

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

RewriteEngine on

RewriteRule ^/this-example/(.*)/ /index.php?$1 [L]

</IfModule>

Options -Indexes

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我正在尝试将附加参数附加到wordpress中。

例如,我有一个URL: http://example.com

我想将其更改为网址: http://example.com/this-example/ </ p>

我在想我能做到这一点 是在重写条件下的htaccess,但我不确定如何去做。 这就是我在这里想的。</ p>

Htaccess </ strong> </ p>

 &lt; IfModule mod_rewrite.c&gt; 

RewriteEngine On

RewriteBase /

RewriteRule ^ index \\ .php $ - [L]

RewriteCond%{REQUEST_FILENAME}!-f

RewriteCond%{REQUEST_FILENAME}!-d

RewriteRule。 /index.php [L]

RewriteEngine on

RewriteRule ^ / this-example /(.*)/ /index.php?$1 [L]

&lt; / IfModule&gt;

Options -Indexes

</ code> </ pre>

</ div>

网友观点:

You can try this:

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{THE_REQUEST} !^/this-example [NC]

# use your own host here, for me is 192.68.10.10

RewriteCond %{HTTP_HOST} 192\\.168\\.10\\.10$ [NC]

RewriteRule !^this-example/ /this-example%{REQUEST_URI} [L,R,NE]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^this-example/(.*)$ $1 [L,QSA]

</IfModule>

Options -Indexes

标签:

提交需求或反馈

Demand feedback