WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Redirecting url with ?p=

[Resolved] Redirecting url with ?p=

  • Hi,
    I have some pages with domain.com/?p=<something> indexed in google, despite enabling permalinks.
    I am trying to rewrite the url to home page and give a Gone response.
    I added the following code to my htaccess file
    [code]
    RewriteCond %{QUERY_STRING} ^p=([0-9]*)$
    RewriteRule / [L,G]
    [/code]
    But, it isn’t working. Looking at the RewriteLog I can see
    [code]

    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (2) init rewrite engine with requested uri /
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) applying pattern ‘^/([^/]+)(.*)’ to uri ‘/’
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (1) pass through /
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ ->
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] applying pattern ‘/’ to uri ”
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ ->
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] applying pattern ‘^index\.php$’ to uri ”
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ ->
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/ ->
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (3) [perdir /var/www/] applying pattern ‘.’ to uri ”
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c5caf0/initial] (1) [perdir /var/www/] pass through /var/www/
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c66b10/subreq] (2) init rewrite engine with requested uri /index.html
    127.0.0.1 – – [25/Jul/2011:16:41:48 +051800] [localhost/sid#20999310][rid#20c66b10/subreq] (3) applying pattern ‘^/([^/]+)(.*)’ to uri ‘/index.html’
    [/code]

    Thus, the QUERY_STRING does not match. What am I doing wrong here? What would be the proper way to handle this?

  • The topic ‘[Resolved] Redirecting url with ?p=’ is closed to new replies.