w3id.org icon indicating copy to clipboard operation
w3id.org copied to clipboard

Checking for duplicates/existing rewrites

Open bsletten opened this issue 9 years ago • 3 comments

As part of an an attempt to automate the checking process, I did some experimentation tonight and came across the following extant rules:

bash-4.3$ for i in find . -type d | cut -c 3-; do echo $i; grep $i .htaccess; done aidan RewriteRule ^aidan$ http://aidan.droppages.com/ [R=302,L] dgarijo fastflo jennybc keski nandana nxg RewriteRule ^nxg$ http://nxg.me.uk/norman/ [R=303,L] ocorcho paolo pfig ssevertson tailot tokarenko RewriteRule ^tokarenko$ http://flavors.me/tokarenko [R=303,L]

We have three directories that duplicate existing rewrite rules. As far as automated checking is concerned, I'd like to prevent someone else adding a directory /people/bsletten if there exists a ^bsletten$ rule in the people/.htaccess file.

I'd like to clean up the three existing rules and then barf in the Travis process if someone is trying this on a PR.

Does this seem like a good strategy? Any issue in doing this?

bsletten avatar Jan 04 '16 03:01 bsletten

In general it seems like a good strategy. Keep in mind apache rewrite minutae. I think if you get rid of the directory rewrite, the following /may not/ work:

https://w3id.org/people/bsletten <--- works https://w3id.org/people/bsletten/ <--- might not work?

The second is only a problem if the following was also desired functionality:

https://w3id.org/people/bsletten/pets/loki

So, you may want to firm up the rules such that:

  1. IF there is an entry in /people/.htaccess for the person, AND
  2. there is a /people/DIR/.htaccess file, AND
  3. the /people/DIR/.htaccess only contains one rewrite rule for ^$, THEN throw an error

msporny avatar Jan 04 '16 14:01 msporny

No objection, here, Brian.

Regards,

Dave

http://about.me/david_wood

On Jan 4, 2016, at 09:53, Manu Sporny [email protected] wrote:

In general it seems like a good strategy. Keep in mind apache rewrite minutae. I think if you get rid of the directory rewrite, the following /may not/ work:

https://w3id.org/people/bsletten <--- works https://w3id.org/people/bsletten/ <--- might not work?

The second is only a problem if the following was also desired functionality:

https://w3id.org/people/bsletten/pets/loki

So, you may want to firm up the rules such that:

IF there is an entry in /people/.htaccess for the person, AND there is a /people/DIR/.htaccess file, AND the /people/DIR/.htaccess only contains one rewrite rule for ^$, THEN throw an error — Reply to this email directly or view it on GitHub.

perma-id avatar Jan 04 '16 18:01 perma-id

Upon further reflection, I am unconvinced this should be an error, maybe just a warning. I'm not sure I'll know what is new and what isn't. If we have a scenario like you describe above and you edit something, I am not sure I'll know whether you are attempting something new or editing something existent. Without having access to the account that created the URL and the account doing the edit, I don't know that I can resolve the two scenarios so a warning might get our attention. But, if we have existing versions like we have, the warning will be firing all the time and will therefore be useless. I'm going to have to noodle on this some more.

bsletten avatar Jan 04 '16 21:01 bsletten