0

mod_rewrite について質問があります。

このようなリンクがあります

http://pagename.com/pl/meskie/longsleevy/criminal-squad#ad-image-0

そして、 # の後のすべてを「カット」して取得したい

http://pagename.com/pl/meskie/longsleevy/criminal-squad

ショップには多くの商品があるため、商品ごとに多くのルールを作成したくありません。だから私はこのようなものを作成しました:

RewriteRule ^/pl/meskie/longsleevy/([[^#]+)#([^#]+)$ ^/pl/meskie/longsleevy/([[^#]+)$

しかし、これは機能していません。誰か助けてくれませんか?

私の実際の.htaccess

<IfModule mod_rewrite.c>

SetEnv HTTP_MOD_REWRITE On

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/media/
RewriteCond %{REQUEST_URI} !^/extAdmin/
RewriteCond %{REQUEST_URI} !^/skin/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php

</IfModule>

ありがとうございました、

4

1 に答える 1

0

What about

RewriteRule ^/pl/meskie/longsleevy/([ˆ#]*)#.*$ /pl/meskie/longsleevy/$1

The brackets () on the left site will store everything before #, then print it with $1 on the right side. Also ^ and $ are useless on the right side.

Also, take care about the greedy .*

If you will change your mind and you want to rewrite url with fragment #, don't forget to add [NE] flag. See https://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne

Further reading apache docs

于 2013-08-23T06:18:36.930 に答える