質問

I have written a rewrite rule in the .htaccess file for my website page:

RewriteRule ^nice_url/$  ?p_action=user_profile&post_author=45 [L]

The full link is: "http://www.example.co.il/nice_url/" it works perfect.

BUT, when I try to create a sitemap (e.g. with http://www.web-site-map.com/), I have an indication that the link "http://www.example.co.il/nice_url/" is broken.

Why?

The link is working fine. Why is it indicated as broken?

Thanks!

役に立ちましたか?

解決 2

Seems that I found the problem:

I have a main .htaccess file that redirects to 3 different folders. Each folder is for a different website (all in the same host).

One of the websites is in WP. The rewrite happens well.

BUT, when I try to generate a sitemap - the wp returns a 404 for the sitemap generator and thats why I get an error.

solution: I'll probably try to rewrite from the php and not from the htaccess.

他のヒント

You can just add another rule to externally redirect long URL to nice URL like this:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+\?p_action=user_profile&post_author=45\s [NC]
RewriteRule ^ nice_url? [R=301,L]

UPDATE: Alright I checked that sitemap generator is putting & instead of & in generated URLs.

You need to add this additional rule to handle this:

# convert & to &
RewriteCond %{QUERY_STRING} ^(.*)&(.*)$ [NC]
RewriteRule ^ %{REQUEST_URI}?%1&%2 [L,R,NE]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top