I would like to create a custom rewrite rule that will take the URL:


but display


Is there any way to do this? I am trying to add the rewrite rule so in my theme's functions.php

add_action( 'init', 'add_custom_rules' );

function add_custom_rules() {

I've tried flushing the rules, but this always seems to enter some kind of loop always going back to the 'login' page.


  1. The URL is actually just 404-ing now
  2. I should add that I do have a page with the slug submit-project and thus the URL: http://domain.com/submit-project in case it matters.
  3. I've installed the plugin Rewrite Rules Inspector and can't seem to find my rule in there.
  • Rewrite rules that don't start with index.php get written to .htaccess instead of being added to the rule array. I'm not entirely sure it would work anyway, since there would probably be issues with the admin cookies working outside of the admin directory and (if using any kind of domain mapping) cross-domain cookie issues as well. – John P Bloch Jan 28 '14 at 19:15
  • Hm, if I'm not mistaken, if the user is not logged in, wouldn't visiting the URL simply forward the user to the login page anyhow? Or is that the issue, that it wouldn't be able to read the cookie even if the user was logged in? – waffl Feb 3 '14 at 10:16

In general, it is possible, but you need to define ADMIN_COOKIE_PATH in your wp-config.php to the value / which might cause security issues.

First of all define this rewrite rules in your .htaccess right before the rewrite rule of wordpress:

# Make sure, there is a trailing slash
RewriteRule ^submit-project/add$ submit-project/add/ [R=301,L]
# mask the urls
RewriteRule ^submit-project/add/$ /wp/wp-admin/post-new.php [L,QSA]
RewriteRule ^submit-project/add/post.php?$ /wp/wp-admin/post.php [L,QSA]
# this is the wordpress rule:
RewriteRule . /index.php [L]

Now you need to define the constant in the wp-config.php

define( 'ADMIN_COOKIE_PATH', '/' );

I recommend not to use this on a productive site. Consider to offer a special input formular in the frontend using shortcodes or something less invasive than the shown example.

  • This worked perfectly. You were right, it has to do with the ADMIN_COOKIE_PATH. – waffl Feb 4 '14 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.