gerrmen Posted March 2, 2019 Share Posted March 2, 2019 Hi, im new here. I im trying to convert this url Quote autor.php?id=division-men to autor/division-men i try with this solution but no results stackoverflow.com/questions/28168375/how-to-write-htaccess-rewrite-rule-for-seo-friendly-url also with: RewriteRule palabra/(.*)/ autor.php?id=$1 [L,QSA,NC] also this: RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+autor\.php\?id=([^\s]+) [NC] RewriteRule ^ /autor/%1/? [R=302,L] thanks for the help! Link to comment Share on other sites More sharing options...
Autofahrn Posted March 2, 2019 Share Posted March 2, 2019 Hello @gerrmen, welcome to the forum! Can you explain a little bit more about the why? For me its currently unclear if the client sends the parameter URL (?id=division-men) and you try to map this to regular pages, or if the client should send a friendly url (/ autor/division-men) and you want to process that one with php. If the latter is the case, then you don't need to modify your .htaccess but want to use URL segments instead. Your template processing the /autor page would then have to evaluate whatever comes next in the URL. 1 Link to comment Share on other sites More sharing options...
gerrmen Posted March 2, 2019 Author Share Posted March 2, 2019 hi thanks for helping me. yes i want map (?id=division-men) to regular pages (friendly urls i need) Link to comment Share on other sites More sharing options...
Autofahrn Posted March 2, 2019 Share Posted March 2, 2019 Sorry, still not clear what you intend to do. For me a "friendly" url (seen in address field of your browser) would be "/autor/division-men". 1 hour ago, gerrmen said: yes i want map (?id=division-men) to regular pages (friendly urls i need) In that case the URL in the browser would read "autor.php?id=division-men", but the content is organized as regular pages in ProcessWire. The obvious question is, where are these URLs coming from? Something legacy? If you only want to tidy up such legacy URLs to friendly pathnames, I'd suggest sending a redirect to the client, which could be accomplished with a simple template. Create a new page template first, name it redirector, for example. On the URLs tab disable enforcement of a trailing slash for such pages ("Should page URLs end with a slash?" -> no). Then create a page using that template and name it autor.php. To be clear, I really mean the name of that page: Create the template code for the template, would be site/templates/redirector.php containing something like this: <?php namespace ProcessWire; $docsRoot = $pages->get('/docs/'); // Point to root where to search $pageName = $input->get->pageName('id'); // Get sanitized page name from GET parameter if($pageName && ($pg = $docsRoot->findOne("name=$pageName"))->id) // Find "the" page { $session->redirect($pg->url); // never come here! } // didn't work, throw 404 in this case throw new Wire404Exception(); So, if your client enters "autor.php?id=division-men" as the URL, he'll be redirected to "/docs/division-men" in this case. Note: $page->findOne requires PW 3.0.116+ Link to comment Share on other sites More sharing options...
bernhard Posted March 3, 2019 Share Posted March 3, 2019 Hi @gerrmen and welcome, did you read the docs about url segments? https://processwire.com/docs/front-end/how-to-use-url-segments/ Seems like this could be what you are looking for. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now